Charlie Zhao <zhaoyu_...@qq.com> added the comment:

> "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.

----------
nosy: +CharlieZhao

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue47031>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to