strange behavior of the comparison operator

Jeff Shannon jeff at ccvcorp.com
Wed Aug 29 14:10:56 EDT 2001


Nicolas Evrard wrote:

> Hello everyone, this is my first post to the list and let me say that I
> find python really exciting ... Looks a bit like scheme but is fast and
> have a large community of users ...
>
> Here 's what I've done :
>
> To try the __comp__ method I've done a class for complex number (the usual
> example). But here are the result I've got :
>

... I think that the real problem here, is that you actually want to be
defining __cmp__ (no 'o').  Your __comp__ method works just fine, but is not
called when using less-than (<) (or any other comparison operator, of course).

Jeff Shannon
Technician/Programmer
Credit International






More information about the Python-list mailing list