[Python-Dev] python 3 niggle: None < 1 raises TypeError

Nick Coghlan ncoghlan at gmail.com
Mon Feb 17 13:12:48 CET 2014

On 17 Feb 2014 21:15, "M.-A. Lemburg" <mal at egenix.com> wrote:
> On 15.02.2014 07:03, Stephen J. Turnbull wrote:
> > 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.
> None is special in Python and has always (and intentionally) sorted
> before any other object. In data processing and elsewhere in Python
> programming, it's used to signal: no value available.

This is the first I've ever heard of that sorting behaviour being an
intentional feature, rather than just an artefact of Python 2 allowing
arbitrarily ordered comparisons between different types. Can you point me
to the relevant entry in the Python 2 language reference?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140217/a608348c/attachment.html>

More information about the Python-Dev mailing list