[Python-Dev] Python semantic: Is it ok to replace not x == y with x != y? (no)
Serhiy Storchaka
storchaka at gmail.com
Wed Dec 16 04:34:37 EST 2015
On 15.12.15 15:04, Victor Stinner wrote:
> Should Python emit a warning when __eq__() is implemented but not __ne__()?
No. Actually I had removed a number of redundant (and often incorrect)
__ne__ implementations after fixing object.__ne__.
> Should Python be modified to call "not __eq__()" when __ne__() is not
> implemented?
__ne__() always is implemented (inherited from object). Default __ne__
implementation calls __eq__() and negate it's result (if not
NotImplemented).
But user class can define __ne__ with arbitrary semantic. That is the
purpose of adding __ne__.
More information about the Python-Dev
mailing list