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
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
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
> >>
>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
Roy Smith wrote:
class Property:
def __init__ (self, block, lot, zoning="Unknown"):
self.block = block
self.lot = lot
self.zoning = zoning
def __hash__ (self):
return (self.block + self.lot)
def __cmp__ (self, other):
# I wish there was a less ver