__eq__ and sets

Alex Martelli aleax at aleax.it
Tue Feb 25 17:54:56 CET 2003

Chris Reedy wrote:

> I recently encountered the following:
>  >>> from sets import Set
>  >>> x = Set([1])
>  >>> x == 2
> TypeError: Binary operation only permitted between sets
> The TypeError is raised by Set.__eq__ (actually BaseSet.__eq__) upon
> recognizing that 2 is not a set.
> My question: Is this the expected and/or appropriate behavior?

I'm not quite sure why all binary operations in sets.py raise
TypeError when the other argument is not a set -- it was that
way when I started working on it and I did not question it.  I
think you should submit a bug report to SF so the BDFL can
Pronounce on it...


More information about the Python-list mailing list