Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'sufficient': 0.05; 'string': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'length.': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'sentinel': 0.16; 'simpson': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'test.': 0.24; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'raise': 0.29; "doesn't": 0.30; 'fault': 0.31; 'something': 0.35; 'picking': 0.36; 'received:com.au': 0.36; 'charset:us-ascii': 0.36; 'similar': 0.36; 'example,': 0.37; 'too': 0.37; 'received:211': 0.38; 'content-disposition:inline': 0.62; "you've": 0.63; 'telling': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; "life's": 0.84 Date: Mon, 27 May 2013 16:13:20 +1000 From: Cameron Simpson To: Vito De Tullio Subject: Re: Short-circuit Logic MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.0 cv=e/de0tV/ c=1 sm=1 a=wom5GMh1gUkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=EnxjxczguSsA:10 a=pGLkceISAAAA:8 a=NHje-ctoFfUnQNg6rFsA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=ChdAjXE5lkUvdteQbhpnkQ==:117 Cc: python-list@python.org 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369635220 news.xs4all.nl 15907 [2001:888:2000:d::a6]:60142 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46172 On 27May2013 06:59, Vito De Tullio wrote: | Cameron Simpson wrote: | > if s is not None and len(s) > 0: | > ... do something with the non-empty string `s` ... | > | > In this example, None is a sentinel value for "no valid string" and | > calling "len(s)" would raise an exception because None doesn't have | > a length. | | obviously in this case an `if s: ...` is more than sufficient :P :P My fault for picking too similar a test. Cheers, -- Cameron Simpson Death is life's way of telling you you've been fired. - R. Geis