On 26.08.2021 10:02, Peter Otten wrote:
> On 26/08/2021 09:36, Marc-Andre Lemburg wrote:
>
>> In Python you can use a simple test for this:
>
> I think you need math.isnan().
>
>>>>> nan = float('nan')
>>>>> l = [1,2,3,nan]
>>>>> d = {nan:1, 2:3, 4:5, 5:nan}
>>>>> s = set(l)
>>>>> nan in l
>> True
>
> That only works with identical nan-s, and because the container omits the
> equality check for identical objects:
>
>>>> nan = float("nan")
>>>> nan in [nan]
> True
>
> But:
>
>>>> nan == nan
> False
>>>> nan in [float("nan")]
> False
Oh, good point. I was under the impression that NAN is handled
as a singleton.
Perhaps this should be changed to make to make it easier to
detect NANs ?!
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, Aug 26 2021)
>>> Python Projects, Coaching and Support ... https://www.egenix.com/
>>> Python Product Development ... https://consulting.egenix.com/
________________________________________________________________________
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
https://www.egenix.com/company/contact/
https://www.malemburg.com/
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/R357YDI5ZV5UG6DZSQISVNICH4IZMNIT/
Code of Conduct: http://python.org/psf/codeofconduct/