Paul Ganssle <p.gans...@gmail.com> added the comment:

@veky I can't be sure, but I think you may not understand what returning 
`NotImplemented` does - this makes comparisons *more* versatile, not less.

The way it works is that when Python does, for example, x == y, it will first 
call x.__eq__(y) and check the return value of that. If that's True or False, 
it will return the value, but if it's NotImplemented, it will call y.__eq__(x) 
and return that value, unless the value is NotImplemented. If both comparisons 
return NotImplemented, it falls back on the default implementation for __eq__, 
which I think is "x is y". For __lt__ it's different fallback behavior, but the 
same general idea.

Most of these changes are going from a situation where __lt__ or __eq__ was 
raising an exception or returning False for comparisons where the operation is 
not defined. This makes the distinction between "I don't know how to compare 
myself to that object" and "I know how to compare myself to that object and I 
am not equal to it".

----------
nosy: +p-ganssle

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37685>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to