Second python program: classes, sorting
Wojtek Walczak
gminick at nie.ma.takiego.adresu.w.sieci.pl
Sun Aug 10 15:32:48 EDT 2008
Dnia Sun, 10 Aug 2008 20:26:51 +0200, WP napisa³(a):
Hi,
> Hello, here are some new things I've problems with. I've made a program
...
> def __cmp__(self, other):
> print "in __cmp__"
> return self.score >= other.score
Check this out: http://docs.python.org/ref/customization.html
Definition of this method should rather look like this:
==========================================
def __cmp__(self, other):
print "in __cmp__"
if self.score == other.score:
return 0
elif self.score > other.score:
return 1
return -1
==========================================
Should work fine now.
--
Regards,
Wojtek Walczak,
http://www.stud.umk.pl/~wojtekwa/
More information about the Python-list
mailing list