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


Groups > comp.lang.python > #15736

Re: suppressing import errors

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.016
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '"if': 0.04; 'not?': 0.09; 'am,': 0.12; '16,': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'namespace.': 0.16; 'subject:import': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; "shouldn't": 0.23; 'header:In-Reply- To:1': 0.23; 'testing': 0.24; 'true,': 0.28; 'message- id:@mail.gmail.com': 0.29; 'module': 0.30; 'nov': 0.31; 'does': 0.32; 'to:addr:python-list': 0.32; 'instead': 0.33; 'there': 0.33; 'david': 0.34; 'object': 0.35; 'none': 0.36; 'received:google.com': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'should': 0.39; 'why': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; '2011': 0.62; 'evaluate': 0.71; 'riley': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=K4DNvygZl5eC3J+6ZK7n+WxqLFlzRhHbc0lLxFxB6I8=; b=JEdboUtq72QhrLobQStSJ6gu5FBvufyHsr0jQCpBvvw7ej8L0Xf+iV3L2pbmXY5hXP nfIwSlq7E29Xz2FtAjf2n2r0aon7Ozwlh44QcBdOW5bhdBK7Td23u5uAsm8yPVSwSQIt DwfKhSaIw8EkB6C8xPhOs7yYDob3UZEMGcOQI=
MIME-Version 1.0
In-Reply-To <0601B8C7-9AEF-443A-A149-0F7D356345EF@gmail.com>
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>
Date Wed, 16 Nov 2011 07:01:40 +1100
Subject Re: suppressing import errors
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
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.2746.1321387303.27778.python-list@python.org> (permalink)
Lines 9
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1321387303 news.xs4all.nl 6987 [2001:888:2000:d::a6]:58868
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15736

Show key headers only | View raw


On Wed, Nov 16, 2011 at 6:39 AM, David Riley <fraveydank@gmail.com> wrote:
> True, and that does avoid polluting namespace.  However, you shouldn't be testing for None as a bool; you should instead do an "if <module> is None:" (or, of course, "is not None").

Why not? Is there some other way for the module object to evaluate as false?

ChrisA

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


Thread

Re: suppressing import errors Chris Angelico <rosuav@gmail.com> - 2011-11-16 07:01 +1100

csiph-web