What is id in Python

The id()
function returns identity (unique integer) of an object.
Syntax: id(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'))
Output:
id of cat = 2555911490960 id of 5 = 140733430699968 id of 5 = 2555909586416
Subscribe
Login
Please login to comment
0 Discussion