Comparing None and ints

Xavier Ho contact at xavierho.com
Tue Jan 17 01:55:06 EST 2012


Good to see Python3 got rid of that confusion :]

Cheers,
Xav



On 17 January 2012 16:50, Chris Angelico <rosuav at gmail.com> wrote:

> On Tue, Jan 17, 2012 at 5:47 PM, Xavier Ho <contact at xavierho.com> wrote:
> > What was the rationale behind this design?  Specifically, (None < 0) ==
> True
> > and (None == 0) == False?
> >
> > Personally I would have expected an exception on all tests above.
>
> Compare with Python 3:
>
> >>> None<0
> Traceback (most recent call last):
>   File "<pyshell#31>", line 1, in <module>
>    None<0
> TypeError: unorderable types: NoneType() < int()
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120117/19aca5e9/attachment-0001.html>


More information about the Python-list mailing list