Steven Bethard wrote:
>     class C(object):
>         def __cmp__(self, other):
>             if self.foo < other.foo:
>                 return -1
>             elif self.foo < other.foo:
>                 return 1
>             else:
>                 return 0

With __cmp__, in cases like that you can punt the whole
thing off to the subsidiary object, e.g.

   def __cmp__(self, other):
     return cmp(self.foo, other.foo)

--
Greg
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to