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


Groups > comp.lang.python > #15742

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!newsfeed5.news.xs4all.nl!xs4all!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.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '"if': 0.04; 'defaults': 0.07; 'compares': 0.09; 'am,': 0.12; '16,': 0.15; 'argument': 0.15; 'boolean': 0.16; 'compact': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'none"': 0.16; 'quicker': 0.16; 'received:209.85.213.174': 0.16; 'received:mail- yx0-f174.google.com': 0.16; 'subject:import': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.23; 'testing': 0.24; 'variable': 0.24; 'message-id:@mail.gmail.com': 0.29; 'equality': 0.30; 'nov': 0.31; 'value.': 0.32; 'to:addr:python-list': 0.32; 'done': 0.33; 'probably': 0.34; 'david': 0.34; 'none': 0.36; 'two': 0.37; 'could': 0.38; 'received:google.com': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'e.g.': 0.38; 'should': 0.39; "it's": 0.39; 'subject:: ': 0.39; 'might': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'really': 0.40; 'more': 0.60; '2011': 0.62; 'hand,': 0.76; 'beware': 0.84; 'container)': 0.84; 'riley': 0.84; '\xa0also,': 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=K8bPFFWKqV9q5Jj3k0/nmSbn3hzJv9DAog2/YACIuZo=; b=EPK42LjaiKDMXJp6bXMwKYxAId4HJ8tyCKeS4PJc/seC2u8uqEQ7O4/tQ0WqWro+JV HNCjdTV16OUapasRlkP/9jvbaRVG8JVfBMuTYbCWVolG8sy86Rs4BeFN7JOoIYsPpkAq LL4COkSq2BLwA1bgQZI2KM5hu6RLKkRXtn7Ww=
MIME-Version 1.0
In-Reply-To <F8266E63-F932-4216-9E33-8333C1D62E43@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> <CAPTjJmrP7fMg9UfxdsR=5j6EW4yFKf8gR4xYQD5zDwMUVxdmjw@mail.gmail.com> <F8266E63-F932-4216-9E33-8333C1D62E43@gmail.com>
Date Wed, 16 Nov 2011 08:34:02 +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.2751.1321392845.27778.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1321392845 news.xs4all.nl 6901 [2001:888:2000:d::a6]:45157
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15742

Show key headers only | View raw


On Wed, Nov 16, 2011 at 8:20 AM, David Riley <fraveydank@gmail.com> wrote:
>      Comparisons to singletons like None should always be done with
>      'is' or 'is not', never the equality operators.
>
>      Also, beware of writing "if x" when you really mean "if x is not None"
>      -- e.g. when testing whether a variable or argument that defaults to
>      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!

It's probably quicker to execute "if x is None" than "if x"
(presumably the former just compares the two pointers). On the other
hand, it's more compact to leave off the "is None". And on the
gripping hand, neither "quicker to execute" nor "more compact" equates
to "more Pythonic".

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 08:34 +1100

csiph-web