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

Chris Barker chris.barker at noaa.gov
Thu Jan 8 00:31:31 CET 2015

On Wed, Jan 7, 2015 at 11: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)?

This "attractive nuisance" exists for ALL python objects, and is especially
attractive for interned ints and strings.

I have a much harder time getting students to use "is None" than getting
them to not use "is" elsewhere.

My summary:

there isn't a huge reason to add math.nan, but there is essentially zero
cost -- what's the problem?



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150107/08c36d8f/attachment.html>

More information about the Python-ideas mailing list