Is sample1 or sample2 the more pythonic way of comparing?

class sample1
        def __init__(self, a, b):
                self.a = a
                self.b = b
        def __cmp__(self, other):
                return self.a.__cmp__(other.a)

...or:

class sample2
        def __init__(self, a, b):
                self.a = a
                self.b = b
        def __cmp__(self, other):
                if self.a < other.a:
                        return -1
                elif self.a > other.a:
                        return 1
                else:
                        return 0

?

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to