Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.05; 'subject:Python': 0.06; '(so': 0.07; 'correct.': 0.07; 'granted,': 0.07; 'odd': 0.07; 'plenty': 0.07; '"if': 0.09; 'immutable': 0.09; 'sentence': 0.09; 'used.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'translation': 0.12; '"is"': 0.16; 'argument.': 0.16; 'arguments:': 0.16; 'buggy': 0.16; 'distinct': 0.16; 'integer,': 0.16; 'justified': 0.16; 'mutable': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'slightly': 0.19; 'examples': 0.20; '>>>': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'sorry,': 0.24; 'specify': 0.24; 'versions': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'equality': 0.31; 'gary': 0.31; 'tuples': 0.31; "we're": 0.32; 'no,': 0.35; 'objects': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'crazy': 0.36; 'useful': 0.36; 'should': 0.36; 'example,': 0.37; 'too': 0.37; 'two': 0.37; 'same.': 0.38; 'pm,': 0.38; 'even': 0.60; 'august': 0.61; "you're": 0.61; 'talking': 0.65; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'ambiguous': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=AFlpik8Tq4HJkTJtOXPPhBkkm8v6iwJP5t/19Fm219c=; b=Kht7I5Pth35zPfw6/NXouqRWbQq7U/xhIJXgeD9giT/J0URnzyNCVMHctLqgjMvoGR aCoPk4CuCoQHtxLa6ptGrP+ThF4Zcp4qZz9+nWorXzwTHSppJyuP4ftk5JPwYD5eAkjS siaFWPM3yDcgvZfHdqlPoZjAwfWCJM60rnoF29hHQXmPS8DWiszWUrX/7wVdNqDELblp O9xvmQL2ZxED1B7RPK3oAP7ak0fBq0O1OXvZBHGMqOdoEh111UTXW2c56AUKEfMEd8BN 3wd83QdojUrXDPI2GodTi/JXfKUsxEN+YxfyTIRtgXfIQyt3hQgJDA2j2YEYrK7ypFGa UzHg== X-Received: by 10.152.19.70 with SMTP id c6mr9025392lae.25.1376193902477; Sat, 10 Aug 2013 21:05:02 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: <20130810114040.6ac78fe8@bigbox.christie.dr> <52067FDA.2030908@gmail.com> <5206B527.6080700@islandtraining.com> <5206DDED.8030506@islandtraining.com> <5207034A.6070608@islandtraining.com> From: Joshua Landau Date: Sun, 11 Aug 2013 05:04:22 +0100 X-Google-Sender-Auth: DLSueIML5aIGQyTCuFAHvCAuCgc Subject: Re: Python Basic Doubt To: Chris Angelico Content-Type: text/plain; charset=UTF-8 Cc: python-list 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376193904 news.xs4all.nl 15952 [2001:888:2000:d::a6]:36482 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52356 On 11 August 2013 04:43, Chris Angelico wrote: > On Sun, Aug 11, 2013 at 4:21 AM, Gary Herron > wrote: >> On 08/10/2013 06:00 PM, Chris Angelico wrote: >>> All it takes is a slightly odd or buggy __eq__ implementation and the >>> == versions will misbehave. To check if an argument is something, you >>> use "is", not ==. >> >> No, sorry, but any use of the word "is" in an English sentence is way too >> ambiguous to specify a correct translation into code. To check "if a >> calculation of some value is a million", you'd write >> value == 1000000 >> not >> value is 1000000 >> even though there are plenty of other examples where "is" would be correct. > > Granted, English is a poor litmus test for code. But in this > particular example, we're talking about immutable types (simple > integers), where value and identity are practically the same. A Python > implementation would be perfectly justified in interning *every* > integer, in which case the 'is' would work perfectly here. The > distinction between the two is important when the objects are mutable > (so they have an identity that's distinct from their current values). I don't follow this argument. Tuples are immutable yet you're crazy if you check their equality with "is". In Python identity and equality are very distinct. I follow (and agree) with the other arguments: "is" is useful and should be used. It's just this part in particular sounds off.