Re: Second python program: classes, sorting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wojtek Walczak

    Re: Second python program: classes, sorting

    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,

Working...