What is id in Python
id() function returns identity (unique integer) of an object.
The identity of the object is an integer that is unique for the given object and remains constant during its lifetime.
# id() function class pet: x = 10 cat = pet() print('id of cat =', id(cat)) print('id of 5 =', id(10)) print('id of a =', id('a'))
id of cat = 2555911490960 id of 5 = 140733430699968 id of 5 = 2555909586416
Please login to comment
View all comments