Terry Reedy schrieb: > "Facundo Batista" <facundobatista at gmail.com> wrote in message > news:e04bdf310708021111g2870662bo5c6fdb3c1c68a9c2 at mail.gmail.com... > | >>> class C(object): > | ... def __cmp__(self, other): > | ... return NotImplemented > | ... > > Given that you 'should' return an int, doing elsewise has undefined > results. Returning anything other than an int or NotImplemented raises an exception. NotImplemented seems to be special cased so that the other object's __cmp__ can be tried too. > | >>> c = C() > | >>> print c < None > > I presume that this translates into c.__compare(None) < 0 which becomes > NotImplemented < 0. The result of that is undefined and interpreter > dependent. No, it becomes id(c) < id(None). See half_compare in Objects/typeobject.c. > This is still NotImplemented < 0 versus NotImplemented < None. As I > understand, such nonsense comparisions will raise exceptions in 3.0. Yes, fortunately. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4