FW: Why float('Nan') == float('Nan') is False

Avi Gross avigross at verizon.net
Fri Feb 15 19:53:43 EST 2019


Greg,

Good eye. You are correct!

Yes, that is a side effect I did not intend when I cut and paste and the
darn spell-checker saw it as useful to make my code act like the start of a
normal text sentence. I just replicated it:

>>> float("  nan")
Nan

As I watched, "nan" went to "Nan"

So, indeed, the transcript lied. I will be more careful.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of Gregory Ewing
Sent: Friday, February 15, 2019 3:51 AM
To: python-list at python.org
Subject: Re: FW: Why float('Nan') == float('Nan') is False

Avi Gross wrote:
> I can see why you may be wondering. You see the nan concept as having 
> a specific spelling using all lowercase and to an extent you are right.

No, he's talking about this particular line from the transcript you
posted:

 >>>float("  nan")
 > Nan

This suggests that the interpreter printed out that particular nan value as
"Nan" with a capital N. But that's not what my Python 3.5.1 interpreter
does:

Python 3.5.1 (default, Jun  1 2016, 13:15:26) [GCC 4.2.1 (Apple Inc. build
5664)] on darwin Type "help", "copyright", "credits" or "license" for more
information.
 >>> float("  nan")
nan

Grant was asking whether that's *really* what your interpreter printed out,
and if so, which version of Python it was, because it's quite a surprising
thing for it to do.

Personally I think it's more likely that the N got capitalised somehow on
the way from your terminal window to the mail message.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list