Deep Down, We're All the Same
We'll cover the following...
Do Python classes behave “oddly”? Let’s find out!
Press + to interact
class FTW:passprint(FTW() == FTW()) # two different instances can't be equalprint(FTW() is FTW()) # identities are also differentprint(hash(FTW()) == hash(FTW())) # hashes should be different as well
So, with two objects that don’t compare equal but have the same hash, will there be a hash collision? Not really; there’s another twist to this story.
Press + to interact
print(id(FTW()) == id(FTW()))
How can two objects ...