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


Groups > comp.lang.python > #15742 > unrolled thread

Re: suppressing import errors

Started byChris Angelico <rosuav@gmail.com>
First post2011-11-16 08:34 +1100
Last post2011-11-16 08:34 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#15742 — Re: suppressing import errors

FromChris Angelico <rosuav@gmail.com>
Date2011-11-16 08:34 +1100
SubjectRe: suppressing import errors
Message-ID<mailman.2751.1321392845.27778.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web