Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'valueerror:': 0.07; 'python': 0.09; 'argument,': 0.09; 'skip:[ 30': 0.09; 'terry': 0.09; 'equality.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'nan': 0.16; 'oct': 0.16; 'reedy': 0.16; 'subject:fails': 0.16; 'summary,': 0.16; 'wrote:': 0.17; '>>>': 0.18; '"",': 0.22; 'defined': 0.22; 'feature': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'skip:[ 10': 0.26; '(most': 0.27; 'checking': 0.27; '(as': 0.27; 'forgot': 0.27; "doesn't": 0.28; "d'aprano": 0.29; 'received:192.168.1.3': 0.29; 'steven': 0.29; 'checks': 0.30; 'fri,': 0.30; 'file': 0.32; 'traceback': 0.33; 'to:addr:python-list': 0.33; 'equal': 0.33; 'list': 0.35; 'identity': 0.35; 'pm,': 0.35; 'except': 0.36; 'but': 0.36; 'thank': 0.36; 'item': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'therefore': 0.65; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply- to:addr:python.org': 0.84; 'mistake': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=XYELPfF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=b2nRVtXOy8EA:10 a=oCZfzfwVXioA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=phWpdDf7YpoA:10 a=kDZx4LYk6i8x-JJqXyMA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Fri, 26 Oct 2012 17:43:08 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: a.index(float('nan')) fails References: <5089F33A.8010804@mrabarnett.plus.com> <508ab917$0$29967$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <508ab917$0$29967$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1351269785 news.xs4all.nl 6963 [2001:888:2000:d::a6]:60020 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:32226 On 2012-10-26 17:23, Steven D'Aprano wrote: > On Fri, 26 Oct 2012 04:00:03 -0400, Terry Reedy wrote: > >> On 10/25/2012 10:19 PM, MRAB wrote: > >>> In summary, .index() looks for an item which is equal to its argument, >>> but it's a feature of NaN (as defined by the standard) that it doesn't >>> equal NaN, therefore .index() will never find it. >> >> Except that is *does* find the particular nan object that is in the >> collection. So nan in collection and list.index(nan) look for the nan by >> identity, not equality. > > So it does. I made the same mistake as MRAB, thank you for the correction. > [snip] Yes, I forgot that Python checks for identity before checking for equality: >>> [float("nan")].index(float("nan")) Traceback (most recent call last): File "", line 1, in [float("nan")].index(float("nan")) ValueError: nan is not in list >>> nan = float("nan") >>> [nan].index(nan) 0