This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author CharlieZhao
Recipients CharlieZhao, docs@python, serhiy.storchaka, slateny, steven.daprano, veky
Date 2022-03-24.09:02:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1648112539.95.0.269044150679.issue47031@roundup.psfhosted.org>
In-reply-to
Content
> "Due to the requirements of the `IEEE-754 standard <https://en.wikipedia.org/wiki/IEEE_754>`_, math.nan and float('nan') are never equal to any other value, including themselves. Use math.isnan to test for NANs."

It seems to me, Steven's description is clear enough to tell us that "Be careful if you want to compare NANs with others". 

One thing to emphasize is that neither `is` nor `==` is a best practice, just like slateny's example, we should be wary of the difference between `float('nan')` and `math.nan`.

Adding an example to the docs would be a good way to let everyone know the difference and use `math.isnan` instead of `is` and `==` to test for NANs.
History
Date User Action Args
2022-03-24 09:02:20CharlieZhaosetrecipients: + CharlieZhao, steven.daprano, docs@python, serhiy.storchaka, veky, slateny
2022-03-24 09:02:19CharlieZhaosetmessageid: <1648112539.95.0.269044150679.issue47031@roundup.psfhosted.org>
2022-03-24 09:02:19CharlieZhaolinkissue47031 messages
2022-03-24 09:02:19CharlieZhaocreate