Why is None <= 0

Christian Heimes lists at cheimes.de
Fri Apr 25 23:45:59 CEST 2008


> In my humble opinion, I think that comparisons involving None should
> return None, but I trust that the designers came up with this for very
> good reasons. As far as I know I've never been bitten by it.

It's fixed in Python 3.x. Python 3.x refuses to compare objects unless
one of both objects has explicit support for both types:

>>> 1 < None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    TypeError: unorderable types: int() < NoneType()




More information about the Python-list mailing list