Re: cmp of multiple attributes

2004-12-22 Thread Alex Martelli
Steven Bethard <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > Comparisons of tuples, lists, etc, are *lexicographical*: the first > > items are compared; iff they're equal, then the second items, and so > > forth. IOW, exactly what you want in this case. > > Just to check my understanding

Re: cmp of multiple attributes

2004-12-22 Thread Steven Bethard
Alex Martelli wrote: Comparisons of tuples, lists, etc, are *lexicographical*: the first items are compared; iff they're equal, then the second items, and so forth. IOW, exactly what you want in this case. Just to check my understanding, this means that: cmp(a0, b0) or cmp(a1, b1) or ... or cm

Re: cmp of multiple attributes

2004-12-22 Thread Alex Martelli
Roy Smith <[EMAIL PROTECTED]> wrote: > >Roy Smith wrote: > >> 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 > >>

Re: cmp of multiple attributes (WAS: Why are tuples immutable?)

2004-12-16 Thread Roy Smith
>Roy Smith wrote: >> 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