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


_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/LYNDVMEXQ2BFIKIB5RCFBMZCIQHDZQ5H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to