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

MRAB python at mrabarnett.plus.com
Mon Jan 12 20:33:24 CET 2015

On 2015-01-12 18:05, Guido van Rossum wrote:
> On Mon, Jan 12, 2015 at 8:54 AM, Chris Barker <chris.barker at noaa.gov
> <mailto:chris.barker at noaa.gov>> wrote:
>     Being able to do x is math.nan, and have that give the answer most
>     commonly wanted would be a nice way to spell, but, again, not worth
>     breaking the now clear definition of "is".
> While this discussion about what the meaning of "is" is is a funny
> in-joke for those who remember the Clinton impeachment trials, that you
> even considered it (and posted about it!) makes me shudder -- Python's
> "is" operator is so closely tied to object identity that to propose
> overriding it as a kind of "category" test makes me wonder if you
> understand Python at all. Proposing to change "==" to make all NaNs
> appear equal would be less earth-shattering -- that might go against all
> IEEE fp standards, but at least Python's "==" operator is intended for
> that purpose.
I was going to say that calling it "isnan" is in keeping with
"isdigit", etc, but those are instance methods!

So, why is it "math.isnan(x)" and not "x.isnan()"?

More information about the Python-ideas mailing list