strange behavior of the comparison operator
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Wed Aug 29 13:58:42 EDT 2001
Wed, 29 Aug 2001 17:17:23 GMT, Grant Edwards <grante at visi.com> pisze:
> def __comp__(self, other):
> if self.r < other.r:
> return -1
> elif self.r > other.r:
> return 1
> else:
> if self.i < other.i:
> return -1
> elif self.i > other.i:
> return 1
> else:
> return 0
Or:
def __comp__(self, other):
return cmp((self.r, self.i), (other.r, other.i))
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list