Searching, I noticed that the id()
function returns an integer and that guarantees be unique and constant for the object.
When comparing two different objects getting results, which may have allowed these different results ??
I saw an example in an ebook that comparison id(Car()) == id (Car())
returns False
but when running the same code returned True
class Car.py
class Car:
pass
Code in Idle
>>> from Car import Car
>>> ferrari = Car()
>>> lamborghini = Car()
>>> id(lamborghini) == id(ferrari)
False
>>> id(Car()) == id(Car())
True