[issue1393] function comparing lacks NotImplemented error
Christian Heimes
report at bugs.python.org
Thu Nov 8 14:28:13 CET 2007
Christian Heimes added the comment:
Additional prints make it easy to understand what happens here:
>>> class Anything:
... def __eq__(self, other):
... print("eq")
... return True
... def __ne__(self, other):
... print("ne")
... return False
...
>>> x = lambda: None
>>> print(x == Anything())
False
>>> print(Anything() == x)
eq
True
>>> y = object()
>>> print(y == Anything())
eq
True
>>> print(Anything() == y)
eq
True
x == Anything() doesn't invoke Anything.__eq__(). It's using
function.__eq__().
----------
nosy: +tiran
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1393>
__________________________________
More information about the Python-bugs-list
mailing list