Why are tuples immutable?
Marc Boeren
m.boeren at guidance.nl
Thu Dec 16 11:53:34 EST 2004
> def __cmp__ (self, other):
> # I wish there was a less verbose way to do this!
> if self.block < other.block:
> return -1
> if self.block > other.block:
> return 1
> if self.lot < other.lot:
> return -1
> if self.lot > other.lot:
> return 1
> return 0
A little less verbose:
def __cmp__ (self, other):
compared = cmp(self.block, other.block)
if not compared:
compared = cmp(self.lot, other.lot)
return compared
HTH, Marc.
More information about the Python-list
mailing list