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

2019-02-15 Thread Avi Gross
ot; went to "Nan" So, indeed, the transcript lied. I will be more careful. -Original Message- From: Python-list On Behalf Of Gregory Ewing Sent: Friday, February 15, 2019 3:51 AM To: python-list@python.org Subject: Re: FW: Why float('Nan') == float('Nan&#

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

2019-02-15 Thread Gregory Ewing
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

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

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 4:15 PM Avi Gross wrote: > > > You shouldn't be testing floats for identity. > > I am not suggesting anyone compare floats. I repeat that a nan is not > anything. Now as a technicality, it is considered a float by the type > command as there is no easy way to make an int th

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

2019-02-14 Thread Avi Gross
', 'fromhex', 'hex', 'imag', 'is_integer', 'real'] >>> id(numpy.nan) 57329632 This time that same address is reused: >>> m = numpy.nan >>> id(m) 57329632 >>> n = numpy.nan >>> id(n) 57329632 So the nu

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

2019-02-14 Thread Chris Angelico
On Fri, Feb 15, 2019 at 2:37 PM Avi Gross wrote: > 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 t

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

2019-02-14 Thread Avi Gross
n) >>> numpya == numpyb False >>> numpya is numpyb True -Original Message- From: Python-list 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 Fal

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

2019-02-14 Thread Grant Edwards
On 2019-02-14, Avi Gross 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.edwardsYow! NANCY!! Why i

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

2019-02-14 Thread Avi Gross
Other people have replied well enough with better ways to do this but I am stuck on WHY this was seen as a way to do this at all. The code was: r = float('Nan') while r==float('Nan'): inp = input("Enter a number\n") try: r = float(inp) except ValueError: r = float