Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15753

Re: suppressing import errors

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 <fraveydank@gmail.com>
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 <fraveydank@gmail.com>
In-Reply-To <4EC2EEC0.2090806@yahoo.com>
Date Tue, 15 Nov 2011 18:15:45 -0500
Content-Transfer-Encoding quoted-printable
References <CAC82khmG+zH3Cd5pRfou+0FED18MHfizLzJL4EM+V+Pw+q17+w@mail.gmail.com> <CALvWhxvc=Ng28YeiL0Onv9YCixfQtOqgLENWJqYgoRSYvo_juA@mail.gmail.com> <CAC82khn3WBjXY7podVq6RX0d0j38w1vbtN3fNOCSGLcu2X_jOw@mail.gmail.com> <D97140E4-9B09-4EAE-BB92-0F038FCDBA5A@gmail.com> <4EC2B656.7050902@sequans.com> <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com> <CAPTjJmrP7fMg9UfxdsR=5j6EW4yFKf8gR4xYQD5zDwMUVxdmjw@mail.gmail.com> <mailman.2750.1321392038.27778.python-list@python.org> <4EC2EEC0.2090806@yahoo.com>
To Alan Meyer <ameyer2@yahoo.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2757.1321398951.27778.python-list@python.org> (permalink)
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

Show key headers only | View raw


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!
>> 
>> 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.
> 
> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: suppressing import errors David Riley <fraveydank@gmail.com> - 2011-11-15 16:20 -0500
  Re: suppressing import errors Alan Meyer <ameyer2@yahoo.com> - 2011-11-15 17:59 -0500
    Re: suppressing import errors David Riley <fraveydank@gmail.com> - 2011-11-15 18:15 -0500

csiph-web