Is this a bug? (__eq__, __lt__, etc.)

Tim Peters tim.one at home.com
Tue May 8 21:34:36 EDT 2001


[Steve Holden]
> Erm, what's this "NotImplemented" thingy, then? Your code as is, run
> as a program and not interactively, gave me:
>
>     NameError: There is no variable named 'NotImplemented'

NotImplemented is a new builtin object in 2.1, introduced for rich comparison
support.  You can read about it in the "Basic Customization" section of the
Language Reference manual for 2.1, along with the description of the new
special __lt__, __le__, __eq__, __ne__, __gt__ and __ge__ methods.  Returning
NotImplemented from one of those is similar in spirit to returning None from
__coerce__:  it's not an error, it just tells Python that the receiving
method had no idea what to do with the arguments, so Python should ask one of
the other arguments what to do.





More information about the Python-list mailing list