Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'root': 0.05; 'compiler': 0.07; 'explicit': 0.07; 'none:': 0.07; 'defines': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'mostly': 0.14; '$3,': 0.16; '__ne__': 0.16; 'cause.': 0.16; 'debugged': 0.16; 'happily': 0.16; 'luckily,': 0.16; 'operation.': 0.16; 'outcomes': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'robust.': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'manual': 0.22; 'header:User-Agent:1': 0.23; 'received:comcast.net': 0.24; '15,': 0.26; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'am,': 0.29; 'points': 0.29; 'subject:list': 0.30; "i'm": 0.30; 'code': 0.31; 'class': 0.32; 'quite': 0.32; 'not.': 0.33; 'something': 0.35; 'but': 0.35; 'possible': 0.36; 'should': 0.36; 'example,': 0.37; 'problems': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'skip:* 10': 0.61; 'first': 0.61; 'interest': 0.64; 'more': 0.64; 'yes': 0.68; '9:00': 0.91; 'write:': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Explanation of list reference Date: Sun, 16 Feb 2014 11:29:53 -0500 References: <13208de8-0f85-4e60-b059-dc087c8fda41@googlegroups.com> <87vbwho1i0.fsf@elektro.pacujo.net> <87mwhtnzdu.fsf@elektro.pacujo.net> <59c876d3-02f5-4f5a-8728-a5098472e03d@googlegroups.com> <6e96ba97-8ad0-4dad-9d11-b27bf9b237d0@googlegroups.com> <878utcmqwo.fsf@elektro.pacujo.net> <8ca61d1a-b4f6-4677-9cd6-ba15c251f173@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <8ca61d1a-b4f6-4677-9cd6-ba15c251f173@googlegroups.com> 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392568208 news.xs4all.nl 2838 [2001:888:2000:d::a6]:36846 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66554 On 2/16/14 9:00 AM, Rustom Mody wrote: > On Saturday, February 15, 2014 7:14:39 PM UTC+5:30, Marko Rauhamaa wrote: >> Mark Lawrence: > >>> I have no interest in understanding object identity, I can write code >>> quite happily without it. > >> Luckily, what we are now debating is mostly terminology and points of >> view where the outcomes are unaffected. > >> However, as an example, it is important to know if you should write: > >> if x is not None: >> ... > >> or if > >> if x != None: >> ... > >> is more robust. > > Yes This is my main beef: > Not that both are possible but that the first is *recommended* and the second not. > I'm not sure why you don't like the recommendation, or if you just want people to be more explicit about why it is recommended. My main reason for preferring "x is not None" is that if x's class defines __ne__ incorrectly, "x != None" can come out wrong. And yes, I have actually debugged problems where that was the root cause. If you use "x is not None", nothing about x's class can interfere with the correct operation. > Something like a C compiler manual advising: > You can write x*8 but its better to drop out into asm and write > shl $3, %eax > -- Ned Batchelder, http://nedbatchelder.com