sorting a dictionary
Alex Martelli
aleax at aleax.it
Wed Feb 5 19:18:32 EST 2003
Peter Abel wrote:
...
> But what I do not understand is why the following doesn't crash:
>>>> d={'a': 41, 'b': 'X', 'd': (1+2j)}
>>>> max(d.values())
> 'X'
>>> 2j>'X'
0
>>> 2j<'X'
1
>>> 2j>43
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: cannot compare complex numbers using <, <=, >, >=
>>>
you CAN compare a complex number to a string -- just not to
any other number. Now, that is a "feature" I'm not going to
try to defend (can anybody think of a GOOD reason, as opposed
to an implementation detail leaking out...?).
Alex
More information about the Python-list
mailing list