[Python-ideas] checking for identity before comparing built-in objects

Guido van Rossum guido at python.org
Tue Oct 9 08:44:12 CEST 2012


This smells like a bug in the != operator, it seems to fall back to not ==
which it didn't used to. More later.....


On Monday, October 8, 2012, Steven D'Aprano wrote:

> On Mon, Oct 08, 2012 at 09:29:42AM -0700, Guido van Rossum wrote:
>
> > It's not about equality. If you ask whether two NaNs are *unequal* the
> > answer is *also* False.
>
> Not so. I think you are conflating NAN equality/inequality with ordering
> comparisons. Using Python 3.3:
>
> py> nan = float('nan')
> py> nan > 0
> False
> py> nan < 0
> False
> py> nan == 0
> False
> py> nan != 0
> True
>
> but:
>
> py> nan == nan
> False
> py> nan != nan
> True
>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org <javascript:;>
> http://mail.python.org/mailman/listinfo/python-ideas
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20121008/6e4d7edc/attachment.html>


More information about the Python-ideas mailing list