On Mon, Oct 12, 2009 at 7:04 PM, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > On Mon, 12 Oct 2009 15:45:30 -0500, Peng Yu wrote: > >> def __cmp__(self, other): >> if self._a < other._a: >> return -1 >> elif self._a > other._a: >> return 1 >> elif self._b < other._b: >> return -1 >> elif self._b > other._b: >> return 1 >> else: >> return 0 > > This can be simplified to: > > return cmp((self._a, self._b), (other._a, other._b))
Assuming you're not using Python 3.x that is. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list