Johannes Bauer wrote: > [EMAIL PROTECTED] schrieb: >> On Nov 20, 1:18 pm, Johannes Bauer <[EMAIL PROTECTED]> wrote: >>> Hello group, >>> >>> I'm porting some code of mine to Python 3. One class has the __cmp__ >>> operator overloaded, but comparison doesn't seem to work anymore with that: >>> >>> Traceback (most recent call last): >>> File "./parse", line 25, in <module> >>> print(x < y) >>> TypeError: unorderable types: IP() < IP() >>> >>> Was there some kind of semantic change? >> Overload __lt__ method. > > Well, of course I could do that, but the python doc says: > > "Called by comparison operations if rich comparison (see above) is not > defined." > http://www.python.org/doc/2.5.2/ref/customization.html > > And my code works just fine with 2.5 - only on 3.0 it doesn't work > anymore. Why is that?
Well the Python 2.5 documentation can't be regarded as a reliable guide to what to expect in 3.0 ... You will observe that __cmp__ no longer appears in the index: http://docs.python.org/dev/3.0/genindex-_.html regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list