A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-March/043287.html below:

[Python-Dev] Rich comparisons

[Python-Dev] Rich comparisons [Python-Dev] Rich comparisonsEdward Loper edloper at gradient.cis.upenn.edu
Fri Mar 19 10:29:40 EST 2004
Michael Hudson wrote:
>  >>> float('nan')
>  nan
>  >>> _ == _
>  False

This means that 'nan' is no longer a well-behaved dictionary key:

     >>> x = {float('nan'):0}
     >>> x[float('nan')] = 1
     >>> print x
     {nan: 0, nan: 1}

Even worse, we get different behavior if we use the "same copy" of nan:

     >>> nan = float('nan')
     >>> x = {nan:0}
     >>> x[nan] = 1
     >>> print x
     {nan: 1}

If we *really* want nan==nan to be false, then it seems like we have to 
say that nan is unhashable.  I'm also disturbed by the fact that cmp() 
has something different to say about their equality:

     >>> cmp(float('nan'), float('nan'))
     0

-Edward


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4