Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'interpreter': 0.05; '"""': 0.07; 'assuming': 0.09; 'correct,': 0.09; 'here?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'behave': 0.16; 'finney': 0.16; 'implies': 0.16; 'lend': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; "type's": 0.16; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'specially': 0.26; 'values': 0.27; 'header:X -Complaints-To:1': 0.27; 'point': 0.28; 'correct': 0.29; 'see,': 0.30; 'membership': 0.31; 'steven': 0.31; 'writes:': 0.31; 'class': 0.32; 'problem': 0.35; 'subject: (': 0.35; 'false': 0.36; 'subject:?': 0.36; 'example,': 0.37; 'wrong': 0.37; 'being': 0.38; 'ben': 0.38; 'needed': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'is.': 0.60; 'myself': 0.63; 'skip:n 10': 0.64; 'skip:\xe2 10': 0.65; 'equals': 0.68; '8bit%:43': 0.74; 'other.': 0.75; '"spam"': 0.84; 'ethan': 0.84; 'furman': 0.84; 'optimisation': 0.84; 'received:125': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Is nan in (nan,) correct? Date: Fri, 06 Mar 2015 14:26:15 +1100 References: <54f90c53$0$12994$c3e8da3$5496439d@news.astraweb.com> <858ufazvff.fsf@benfinney.id.au> <54F91C70.6020303@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Cancel-Lock: sha1:mWNSIYh+x7DlAq0ZytjpYJpKWb8= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425612620 news.xs4all.nl 2888 [2001:888:2000:d::a6]:50784 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:86978 Ethan Furman writes: > On 03/05/2015 06:55 PM, Ben Finney wrote: > > > class NullType(object): > > """ A type whose value never equals any other. > > > > This type's values will behave correctly when tested for > > membership in a collection:: > > > > >>> foo = NullType() > > >>> bar = NullType() > > >>> foo is foo > > True > > >>> foo is bar > > False > > >>> foo == foo > > False > > >>> foo == bar > > False > > >>> quux = [foo, "spam"] > > >>> "spam" in quux > > True > > >>> foo in quux > > True > > Did you mean False here? Because True is current behavior. Isn't the point at issue that the Python interpreter *may* optimise by assuming ‘is implies equality’, so the ‘in’ operator can fail if that assumption is false? I thought the problem was that types with custom behaviour, as with the ‘NullType’ example, needed to deal specially with the ‘is implies equality’ optimisation Steven explained. If that's the correct behaviour, and we can *depend* on it being correct, then I don't see what the problem is. -- \ “What I have to do is see, at any rate, that I do not lend | `\ myself to the wrong which I condemn.” —Henry Thoreau, _Civil | _o__) Disobedience_ | Ben Finney