__eq__ and sets

Rene Pijlman reageer.in at de.nieuwsgroep
Tue Feb 25 11:57:47 EST 2003


Chris Reedy:
> >>> from sets import Set
> >>> x = Set([1])
> >>> x == 2
>TypeError: Binary operation only permitted between sets
[...]
>My question: Is this the expected and/or appropriate behavior?
>
>In the case in question, I was expecting false to be returned. 

This is indeed what Python 2.2 returns on uncomparable type
combinations:

>>> 2  == "foo"
0
>>> 2 == [2,3]
0
>>> [2,3] == {2:"foo", 3:"bar"}
0

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl




More information about the Python-list mailing list