Hrvoje Niksic:
> You're right.  The OP states he implements __eq__, so he also needs a
> matching __hash__, such as:
>
>     def __hash__(self, other):
>         return (hash(self.xcoord) ^ hash(self.ycoord) ^
>                 hash(self.streetname) ^ hash(self.streetno))

The hash function by Otten is better because it considers the order of
the items too (while I think the xor doesn't):

return hash((self.xcoord, self.yccord, self.streetname,
self.streetno))

Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to