[Python-3000] None in Comparisons
Tim Peters
tim.peters at gmail.com
Tue Nov 11 19:20:26 CET 2008
[M.-A. Lemburg]
> ...
> That's fine. I'm just talking about the special case for None that
> has existed in Python for years - and for a good reason.
That's overstating it a bit ;-) In Python 1.5.1, comparisons were
changed so that objects of numeric types compared smaller than objects
of non-numeric types, and then 0 < None was true, not None < 0 (which
became true substantially later). The reason for that change is
explained in Misc/HISTORY (it was an attempt to preserve transitivity
across chains of mixed-type comparisons).
Later, during the move to rich comparisons, I was hacking the code in
the same room with Guido, and realized something special had to be
done with None.
"Hey, Guido, what should we do about mixed-type comparisons against None?"
"Hmm ... what do you think?"
"Hmm ... OK, let's make None smaller than other types."
"Why?"
"Oh, why not?"
"Good enough -- but let's not document it -- it's an arbitrary
implementation detail."
"Of course!"
In any case, we thought this was so arbitrary that we didn't hesitate
to break that, up until that time, "0 < None" /had/ been true "for
years - and for a good reason" ;-)
not-all-good-reasons-are-particularly-good-ly y'rs - tim
More information about the Python-3000
mailing list