[Python-Dev] python 3 niggle: None < 1 raises TypeError
Stephen J. Turnbull
stephen at xemacs.org
Sat Feb 15 07:03:59 CET 2014
M.-A. Lemburg writes:
> IMO, it was a mistake to have None return a TypeError in
> comparisons, since it makes many typical data operations
> fail, e.g.
I don't understand this statement. The theory is that they *should*
fail.
The example of sort is a good one. Sometimes you want missing values
to be collected at the beginning of a list, sometimes at the end.
Sometimes you want them treated as top elements, sometimes as bottom.
And sometimes it is a real error for missing values to be present.
Not to mention that sometimes the programmer simply hasn't thought
about the appropriate policy. I don't think Python should silently
impose a policy in that case, especially given that the programmer may
have experience with any of the above treatments in other contexts.
More information about the Python-Dev
mailing list