Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'expected.': 0.09; 'def': 0.12; 'bug': 0.12; '"=="': 0.16; '"is"': 0.16; 'behaviour.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'aug': 0.22; 'equivalent': 0.26; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'needed.': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'gary': 0.31; 'class': 0.32; 'cases': 0.33; 'device': 0.34; "can't": 0.35; 'something': 0.35; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'example,': 0.37; 'represent': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'easy': 0.60; "you're": 0.61; 'more': 0.64; 'results': 0.69; 'imagine': 0.93; '2013': 0.98 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=Iqv3qCFyTCgNA7QY6qYo3sfu8DyT7ss0fKCDbNhVgBA=; b=btWm4Y//W1fkXF8N+RtC123BPiZPC44dMjB3NQ9VcIYj1Qt35gX1wue1QeSu+OPnQV rvAXQ6AsrgqWe7oZiROOWm0Hn3/cCBrPNu2U+V7BuCUBH6PEgyT1Dk9f5PxbvrzRxF8B zqSdjCu4rj4HMSqXnzzbJiD4Fp0ZXcJmV9dZPfa5m2MIES8Yh9N6RaA0+HCf8QE3RFTv pFbtK1IqJBGD848aXE9tSVOp24a8YUWpIgufCRBJ1z3/xmNoITtLDsvI3p6656dPunTs M/3kGH1iWb9RVLafPqEbQzYLobFCHUVpI/2EYEz4kmhM44HFde+tGvjVARLbPfflhjA+ hWtw== MIME-Version: 1.0 X-Received: by 10.52.27.207 with SMTP id v15mr7503941vdg.83.1376184739622; Sat, 10 Aug 2013 18:32:19 -0700 (PDT) In-Reply-To: References: <20130810114040.6ac78fe8@bigbox.christie.dr> <52067FDA.2030908@gmail.com> <5206B527.6080700@islandtraining.com> <5206DDED.8030506@islandtraining.com> Date: Sun, 11 Aug 2013 02:32:19 +0100 Subject: Re: Python Basic Doubt From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376184743 news.xs4all.nl 15863 [2001:888:2000:d::a6]:45931 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52342 On Sun, Aug 11, 2013 at 2:25 AM, Terry Reedy wrote: > On 8/10/2013 8:42 PM, Gary Herron wrote: > >> But for each of your examples, using "==" is equivalent to using "is". >> Each of >> if something == None >> if device == _not passed >> if device != None >> would all work as expected. In none of those cases is "is" actually >> needed. > > > class EqualAll: > def __eq__(self, other): return True That's a contrived example, of course, but it's easy to have a bug in __eq__ that results in the same behaviour. I can't imagine any code that would actually WANT that, unless you're trying to represent Animal Farm. class EqualAll: def __eq__(self, other): if (isinstance(other, pig): return 3 # Some are more equal than others return True ChrisA