Dennis Sweeney <[email protected]> added the comment:
The one twist is that if type(b) is a strict subtype of type(a), then "a < b"
first calls type(b).__gt__(b, a), then falls back to type(a).__lt__(a, b).
Example:
>>> class Int(int):
... def __gt__(self, other):
... print("Here!")
... return int(self) > int(other)
...
...
>>> 5 < Int(6)
Here!
True
see
https://github.com/python/cpython/blob/da2e673c53974641a0e13941950e7976bbda64d5/Objects/object.c#L683
So I think replacing "a.__lt__(b)" with "a < b" would be an unnecessary change
in behavior, since "a < b" still has to decide which method to use.
I think instead "a.__lt__(b)" could be replaced with "type(a).__lt__(a, b)"
----------
nosy: +Dennis Sweeney
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44605>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com