On 04/08/2013 23:35, Markus Rother wrote:
Hello,
The following behaviour seen in 3.2 seems very strange to me:
As expected:
>>> () == []
False
However:
>>> ().__eq__([])
NotImplemented
>>> [].__eq__(())
NotImplemented
And:
>>> bool(NotImplemented)
True
Hence:
>>> bool(().__eq__([]))
True
>>> ( () == [] ) != ( ().__eq__([]) )
True
How/why can this be intended?
The docs say:
"""NotImplemented
This type has a single value. There is a single object with this value.
This object is accessed through the built-in name NotImplemented.
Numeric methods and rich comparison methods may return this value if
they do not implement the operation for the operands provided. (The
interpreter will then try the reflected operation, or some other
fallback, depending on the operator.) Its truth value is true.
"""
--
http://mail.python.org/mailman/listinfo/python-list