Grant,

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.

As I pointed out. In the context of a string to convert to a float, any
upper/lower-case spelling of NaN is accepted.

But, to answer you anyway, I actually use many versions of python as I have
loaded direct versions as well as through Cygwin and the Anaconda
distribution. Should not be relevant as explained.

But when displaying a value that is of that not-quite-type, all versions
have a print definition as all lower case as in 'nan' I think.

But here is a curiosity. The numpy add-on package has a nan that is UNIQUE
so two copies are the same. Read this transcript and see if it might
sometimes even be useful while perhaps confusing the heck out of people who
assume all nans are the same, or is it all nans are different?

>>> floata = float('nan')
>>> floatb = float('nan')
>>> floata, floatb
(nan, nan)
>>> floata == floatb
False
>>> floata is floatb
False

>>> numpya = numpy.nan
>>> numpyb = numpy.nan
>>> numpya, numpyb
(nan, nan)
>>> numpya == numpyb
False
>>> numpya is numpyb
True


-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon....@python.org> On
Behalf Of Grant Edwards
Sent: Thursday, February 14, 2019 6:15 PM
To: python-list@python.org
Subject: Re: FW: Why float('Nan') == float('Nan') is False

On 2019-02-14, Avi Gross <avigr...@verizon.net> wrote:

> I experimented a bit:
>
>>>> float("nan ")
> nan
>>>> float("  nan")
> Nan
>>>> float("  nAn")
> nan

That's curious.  I've never seen "Nan" before.  What version of Python are
you using?

-- 
Grant Edwards               grant.b.edwards        Yow! NANCY!!  Why is
                                  at               everything RED?!
                              gmail.com            

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

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

Reply via email to