Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '"if': 0.04; '(rather': 0.09; '[],': 0.09; 'difference,': 0.09; 'etc).': 0.09; 'false,': 0.09; 'namespace': 0.09; 'says,': 0.09; 'cc:addr:python-list': 0.15; 'aesthetic': 0.16; 'boolean': 0.16; 'general.': 0.16; 'none"': 0.16; 'not;': 0.16; 'obviously,': 0.16; 'subject:import': 0.16; 'meant': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.21; '(or': 0.22; "doesn't": 0.23; 'received:209.85.212.46': 0.23; 'received:mail-vw0-f46.google.com': 0.23; 'alan': 0.23; 'module,': 0.23; 'pep': 0.23; 'header:In-Reply-To:1': 0.23; 'cc:2**0': 0.25; 'guess': 0.25; 'invalid': 0.28; 'bit': 0.28; 'anyway.': 0.28; 'cc:addr:python.org': 0.29; 'module': 0.30; 'nov': 0.31; 'pm,': 0.31; 'value.': 0.32; 'actually': 0.33; 'it.': 0.33; 'too': 0.33; 'apply': 0.33; 'message-id:@gmail.com': 0.34; 'received:209.85.212': 0.34; 'david': 0.34; '...': 0.36; 'none': 0.36; 'charset:us-ascii': 0.36; 'variables': 0.36; 'doing': 0.37; 'but': 0.37; 'could': 0.38; 'received:google.com': 0.38; 'some': 0.38; 'perhaps': 0.38; 'received:209.85': 0.38; 'received:192': 0.38; "it's": 0.39; 'why': 0.39; 'subject:: ': 0.39; 'under': 0.39; 'might': 0.39; 'difference': 0.40; 'received:209': 0.40; 'really': 0.40; 'more': 0.60; 'your': 0.61; 'header:Message-Id:1': 0.62; 'evaluate': 0.71; 'to:addr:yahoo.com': 0.83; 'bitten': 0.84; 'container)': 0.84; 'received:192.168.8': 0.84; 'riley': 0.84; 'meyer': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=28Rh9QTh2K4pX236dCKs7j/7uKdX+Iu/2ASrDxYjCrU=; b=Xf3kYRJQZtj0NEaoZ4WOtbPZpT3Ras1CDJfwn3Ekx2pkgYOauOXWzdAiPaLZxI+j6w U0uYWg7R7CIskjVtRRElbl+8kUiYatQ0PKAB49vRQSUNmUq6RtUcUVE6wqzy526w8hh9 ryBhiaGPjyqBUVHk8o1MY4dHlQpEc5443cz3g= Subject: Re: suppressing import errors Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: David Riley In-Reply-To: <4EC2EEC0.2090806@yahoo.com> Date: Tue, 15 Nov 2011 18:15:45 -0500 Content-Transfer-Encoding: quoted-printable References: <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> <4EC2EEC0.2090806@yahoo.com> To: Alan Meyer X-Mailer: Apple Mail (2.1251.1) Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321398951 news.xs4all.nl 6874 [2001:888:2000:d::a6]:39859 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15753 On Nov 15, 2011, at 5:59 PM, Alan Meyer wrote: > On 11/15/2011 4:20 PM, David Riley wrote: > ... >> None was set to some other value. The other value might have a = type >> (such as a container) that could be false in a boolean context! >>=20 >> Obviously, that last bit doesn't apply to modules; they're not going = to evaluate as False in general. I just bristle when I see people = writing "if x" when they really mean "if x is not None", perhaps because = it's not The Right Way(tm)? It mostly comes down to aesthetics, I = guess. Write what you really mean. >=20 > Actually Dave, as your quote from PEP 8 says, the difference is real. = It's not just aesthetics. I guess I meant it's aesthetics when it comes down to determining = whether a module is None or not; a module is never going to evaluate to = False under any feasible circumstances. It's not an aesthetic = difference when you consider that the global (or local) namespace may be = polluted with other variables that have the same name as your module, = but then your evaluation would be entirely invalid anyway. But yes, in the general case, it's much more than an aesthetic = difference, which is why I always write "if x is None" when I want to = know if it's None (rather than False, 0, [], "", etc). I have been = bitten way too many times by doing the lazy thing to keep doing it. - Dave