Why is None <= 0

"Martin v. Löwis" martin at v.loewis.de
Fri Apr 25 14:46:17 EDT 2008


>>>> None <= 0
> True
> 
> Why?
> Is there a logical reason?

None is smaller than anything. The choice of
making it so is arbitrary, however, Python 2.x
tries to impose a total order on all objects (with varying
success), therefore, it is necessary to take arbitrary
choices.

(FWIW, in 2.x, x>=4?, it's None < numbers < anything else;
numbers are ordered by value, everything else is ordered
by type name, then by address, unless comparison functions
are implemented).

Regards,
Martin



More information about the Python-list mailing list