Rich Comparisons Gotcha

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Mon Dec 8 00:20:12 CET 2008


On Sun, 07 Dec 2008 15:32:53 -0600, Robert Kern wrote:

> Rasmus Fogh wrote:
> 
>> Current behaviour is both inconsistent and counterintuitive, as these
>> examples show.
>> 
>>>>> x = float('NaN')
>>>>> x == x
>> False
> 
> Blame IEEE for that one. Rich comparisons have nothing to do with that
> one.

There is nothing to blame them for. This is the correct behaviour. NaNs 
should *not* compare equal to themselves, that's mathematically 
incoherent.

-- 
Steven



More information about the Python-list mailing list