[Python-ideas] checking for identity before comparing built-in objects

Steven D'Aprano steve at pearwood.info
Tue Oct 9 06:32:36 CEST 2012


On Mon, Oct 08, 2012 at 04:39:52PM -0400, Ned Batchelder wrote:

> How about:
> 
> "In accordance with the IEEE 754 standard, when NaNs are compared to any 
> value, even another NaN, the result is always False, regardless of the 
> comparison.  This is because NaN represents an unknown result.  There is no 
> way to know the relationship between an unknown result and any other 
> result, especially another unknown one.  Even comparing a NaN to itself 
> always produces False."

Two issues:

1) It is not the case that NaN <comp> NaN is always false.

2) "invalid result" is more appropriate than "unknown result".



-- 
Steven



More information about the Python-ideas mailing list