strange behavior of the comparison operator
Nicolas Evrard
nicoe at wanadoo.be
Wed Aug 29 11:18:46 EDT 2001
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 :
>>> Complex(7,2).__comp__(Complex(3,4))
1
>>> Complex(7,2) < Complex(3,4)
1
the definition of __comp__ I've done :
def __comp__(self, other) :
if self.r < other.r :
return -1
elif self.r == other.r :
if self.i < other.i :
return -1
elif self.i == other.i : return 0
else : return 1
But in the reference manual it says that __comp__ should return a positive
integer if self > other ... and obviously it isn't the case.
BTW i'm using python 1.5.2
--
--------------------------------------- -°)
Evrard Nicolas Happily using: /\\
Liège (Belgium) DEBIAN GNU\LINUX _\//
-------------------------------------------
More information about the Python-list
mailing list