What's the value of "None" between 2.1.1 and 1.5.2

Tim Peters tim.one at home.com
Fri Nov 30 19:10:37 CET 2001


[Michael Abbott]
>>> So why don't comparisons of this type generate an exception?

More than half the reason is historical:  in its early years, it was
technically impossible for Python to "notice" exceptions raised by
comparisons (you could raise them, but they were ignored, and the reason cut
"deep").  After that, backward compatibility kicked in (e.g., there are many
complaints that non-equality comparison of complex numbers now raises an
exception, and despite that the result we used to return didn't make much
sense).

[Steve Holden]
>> Because comparisons are used in sorts, for example, and it wasn't
>> considered helpful for sorts of lists of arbitrary datatypes to raise
>> errors.

That's the other half.

[Michael Abbott]
> Sigh.  I understand.
>
> Of course, if you are sorting a list of arbitrary datatypes using random
> datatypes as the key then you're in a state of sin.

More like potential sin <wink>:  many applications for sorting couldn't care
less about a total ordering, they merely want to make "equal" elements
adjacent, to simplify "the next" step -- and list.sort() is sometimes used
to segregate the elements of a huge heterogeneous list by type.  If we could
do it over again ...





More information about the Python-list mailing list