None always smaller than any data type in Python 2 (see object.c ).
In Python 3, this has been changed; now making comparisons on things without reasonable natural ordering in a TypeError . From 3.0 "what new" updates :
Python 3.0 simplified the rules for streamlining comparisons:
Order comparison operators ( < , <= , >= , > ) raise a TypeError exception when the operands have no meaningful natural ordering. Thus, expressions such as: 1 < '' , 0 > None or len <= len are no longer valid and, for example, None < None raises a TypeError instead of returning False . The corollary is that sorting a heterogeneous list no longer makes sense - all elements must be comparable with each other. Note that this does not apply to the == and != Operators: objects of different incomparable types are always compared unevenly with each other.
This upset some people because it was often convenient to do things like sort a list that had some None values ββand have None values ββgrouped together at the beginning or end. There has been a thread on the mailing list in the past , but the end point is that Python 3 is trying to avoid making arbitrary ordering decisions (which was a lot in Python 2).
John Feminella Feb 06 '10 at 18:38 2010-02-06 18:38
source share