Re: [Distutils] [Python-Dev] Rich Comparison recipe wrong?
2010/1/25 Łukasz Rekucki <lrekucki@gmail.com>:
No, cause what the snippet does is: *not B.__lt__(A)* which is mathematicly correct and doesn't require A to implement anything.
Yes, sorry, it's when you do a > b the problem arises. 1. a > b first tries a.__gt__(b) 2. b.__gt__(b) in turn does b < a 3. Python's first attempt of b < a is calling b.__lt__(a) 4. but b.__lt__(a) returns NotImplemented 5. Python then tries the opposite, which is a.__gt__(b) 6. Goto 2 Infinite recursion.
On Mon, Jan 25, 2010 at 13:43, Lennart Regebro <lregebro@jarn.com> wrote:
2010/1/25 Łukasz Rekucki <lrekucki@gmail.com>:
No, cause what the snippet does is: *not B.__lt__(A)* which is mathematicly correct and doesn't require A to implement anything.
Yes, sorry, it's when you do a > b the problem arises.
and well, a != b, a == b and a <= b But a < b works.
participants (1)
-
Lennart Regebro