On 7/25/2019 4:19 PM, Kyle Stanley wrote:
Serhiy Storchaka wrote:
Actually, the == operator cannot return NotImplemented.
Thanks for the clarification. What is the reason for this limitation and is it
only possible for the `==` operator to return one of `None`, `False`, or
`True`? It seems like it would be useful for it to be able to return
`NotImplemented` in situations such as this.
Because no one is testing for it. And just using it in a boolean context
will return True.
Also, I think that I may have had some misconceptions with regards to the
relationship between the `__eq__()` method and the `==` operator. I know they
are not the same, but isn't the result of the `==` operator based on a
transformation of the result from `__eq__()`?
"Based on", yes. If all of the options return NotImplemented, it falls
back on identity comparison. I can't find this in the Python 3 docs, but
it's no doubt somewhere.
Eric
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/LLE35RZQF3WMLJMMIIREUGJNMIVQBN3P/