This is possible in python2:
None < float('-inf')
Also, it always returns
True
However, on python3, this throws
TypeError: unorderable types: NoneType() < int()
Why is None
comparable to integers/floats with python2? Are there any benefits or applications to None
being orderable in python2?
First of all Python 2 allowed comparing all types of mixed types. This wart was fixed in Python 3 eventually.
For
None
a quick decision was made by Guido and Tim Peters and it resulted in this commit in Python 2.1(emphasis mine):