__eq__ and sets

Rene Pijlman reageer.in at de.nieuwsgroep
Tue Feb 25 17:25:45 EST 2003


Erik Max Francis:
>Rene Pijlman wrote:
>> 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
>
>Well, usually:
>
>>>> 2+1j < 1+2j
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>TypeError: cannot compare complex numbers using <, <=, >, >=

But you can using == and that's what this thread was about :-)

>>> 2+1j == 1+2j
0
>>> 2+1j == [1,2]
0
>>> 2+1j == "foo"
0

Perhaps my "uncomparable" was inaccurate and I should have said
"unequalable" (is that the right word?).

-- 
René Pijlman

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




More information about the Python-list mailing list