On Tue, Nov 18, 2008 at 1:59 AM, Gabriel Genellina
<[EMAIL PROTECTED]> wrote:
> Yes, __cmp__ is gone in 3.0
> You said you wrote __cmp__ the same as __eq__ and that's wrong, they return
> different results. Try something like this (untested):
>
> class X:
>  def __init__(self, a): self.a = a
>  def __cmp__(self, other): return cmp(self.a, other.a)
>  def __hash__(self): return hash(self.a)
>
> x1 = X(1)
> x2 = X(2)
> x3 = X(3)
> x4 = X(1)
>
> print len(set([x1, x2, x3, x4]) # should be 3!

Yes, this works. Thanks.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to