[Python-ideas] math.inf and math.nan constants

Guido van Rossum guido at python.org
Wed Jan 7 23:18:37 CET 2015


On Wed, Jan 7, 2015 at 2:13 PM, Chris Angelico <rosuav at gmail.com> wrote:

> On Thu, Jan 8, 2015 at 6:02 AM, Bruce Leban <bruce at leban.us> wrote:
> > There is a problem here but that's not it. The problem is that
> >
> > float("nan") is float("nan") => False
> > math.nan is math.nan => True
> >
> >
> > So is this an attractive nuisance that will make people think they can
> > should use x is math.nan instead of math.isnan(x)? Hopefully not but
> > something to consider. Pylint should flag this usage.
>
> I don't think that's a problem. Using 'is' to test floating-point
> values is already broken:

[...]
>

Correct. And the first half of the thread was comparing the convenience of
defining a nan constant at the top of your module using "nan =
float('nan')" with "from math import nan". That would have the exact same
'is' problem.

There is no attractive nuisance here except that this thread itself is
wasting everybody's time. :-)

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


More information about the Python-ideas mailing list