4 ms·
It makes sense if you realise that a == b means a,b have the same type and their values are equal. Which is wrong. In Python, "a == b" is: True if a.__eq__(b
by ubernostrum 8y ago
It makes sense if you realise that a == b means a,b have the same type and their values are equal.
Which is wrong.
In Python, "a == b" is:
True if a.__eq__(b) is True (short-circuiting the entire expression to True), or if a.__eq__(b) is NotImplemented and b.__eq__(a) is True.
False if a.__eq__(b) is False (short-circuiting the entire expression to False), or if a.__eq__(b) is NotImplemented and b.__eq__(a) is True.
TypeError if a.__eq__(b) is NotImplemented and b.__eq__(a) is NotImplemented.
- ubernostrum 8y agoSecond line should read as below, can't edit: False if a.__eq__(b) is False (short-circuiting the entire expression to False), or if a.__eq__(b) is NotImplemented and b.__eq__(a) is False.