Look at the following example.
>>> class X:
pass
>>> Y = X
>>> X
<class '__main__.X'>
>>> Y
<class '__main__.X'>
>>> Y == X
True
>>> Y is X
True
The above code is understandable. But, look at the below one.
>>> X = type('X', (), {})
>>> Y = type('X', (), {})
>>> X
<class '__main__.X'>
>>> Y
<class '__main__.X'>
>>> X == Y # Shouldn't this be True??
False
>>> X is Y
False
Here X is Y == False
is as expected. But how come X == Y
is False
?
They both are of same class type, ain't they?