Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeder2.news.elisa.fi!feeder1.news.elisa.fi!newsfeed2.funet.fi!newsfeeds.funet.fi!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!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.038 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:not': 0.03; 'cpython': 0.05; "subject:' ": 0.07; 'objects,': 0.09; 'martin': 0.11; 'confuse': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'to:name :python-list@python.org': 0.22; 'comparing': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; '>>>>': 0.31; 'objects': 0.35; 'received:google.com': 0.35; 'false': 0.36; 'object,': 0.36; 'example,': 0.37; 'wrong': 0.37; 'two': 0.37; 'easily': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'anytime': 0.60; 'most': 0.60; 'such': 0.63; 'answer.': 0.68; '257': 0.84; 'ethan': 0.84; 'furman': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Ga8+Zf6mxIZC5a6TFMKSZCOwXRpQUEp3CWAuB55tqiQ=; b=BPduCXPphru+e3gVNB2Rj7i7XOXbmTCKPmOQqZIlYdc5dt2MXxfVuu0a4sC34p98RK 6gyDfmuuNKWSOirg21KV2kcOEbG05OGWOeb9xt/pL1eX337P4n+1eyHVNDJo/8Fo4NXq elUWWSIinuCz0j52m/QrvGvkReMI8f5ZmguvXi1s8neju8i/0+mNt9hH5c8Vmd0dB1lk kOFYIrhmoN06VU+w2LlmL6DNRBMzlcRPGVIBomSof7qplsMMzMFON9aw0Cpd9iAGbCtk t0cwGT8WfmWEn5HsOI5Jkr0XvvTogxsHkEIx13yRSAgTyLQ0lA1M/JLswKrCYOMprlUN puGQ== MIME-Version: 1.0 X-Received: by 10.52.234.228 with SMTP id uh4mr29797817vdc.34.1408452154794; Tue, 19 Aug 2014 05:42:34 -0700 (PDT) In-Reply-To: References: <87fvgt7c4i.fsf@elektro.pacujo.net> <53F27340.90604@stoneleaf.us> Date: Tue, 19 Aug 2014 14:42:34 +0200 Subject: Re: 'is not' or '!=' From: Martin S To: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408452497 news.xs4all.nl 2830 [2001:888:2000:d::a6]:43149 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76559 2014-08-19 0:04 GMT+02:00 Chris Kaynor : > > On Mon, Aug 18, 2014 at 2:42 PM, Ethan Furman wrote: >> >> If you are not dealing with singletons (which is most cases), such as >> numbers, strings, lists, and most other arbitrary objects, you will need to >> use "!=" or anytime the two objects you are comparing are not the exact same >> object, you can easily get the wrong answer. > > > For example, in CPython 3.4.1: >>>> (254 + 3) is 257 > False >>>> (254 + 3) == 257 > True >>>> ('asd' + '@sd') is 'asd@sd' > False >>>> ('asd' + '@sd') == 'asd@sd' > True Now you have managed to confuse this newbie: What would a valid "is-example" look like? Regards, Martin S