More damage to intuition (was RE: [Python-Dev] Comparison of recursive objects)

Tim Peters tim.one@home.com
Mon, 22 Jan 2001 15:01:59 -0500


[Guido]
> ...
> While fixing the test_b1 code again, which depends on this behavior, I
> thought of a refinement: it wouldn't be hard to make None compare
> smaller than *anything* (including numbers).
>
> Is this worth it?

First, an attempt to see what Python did in this morning's CVS turned up an
internal error for Jeremy:

>>> [None < x for x in (1, 1L, 1j, 1.0, [1], {}, (1,))]
name: None, in ?, file '<stdin>', line 1
locals: {'[1]': 0, 'x': 1}
globals: {}
Fatal Python error: compiler did not label name as local or global

abnormal program termination

A simpler way to provoke that:

>>> [None < 2 for x in "x"]
name: None, in ?, file '<stdin>', line 1
locals: {'[1]': 0, 'x': 1}
globals: {}
Fatal Python error: compiler did not label name as local or global


Anyway, I think forcing None to be "the smallest" is cute!  Inexpensive to
do, and while I don't see a compelling *use* for it, I bet it would be least
surprising to newbies.  +1.