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


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

Re: suppressing import errors

Started byDavid Riley <fraveydank@gmail.com>
First post2011-11-15 14:39 -0500
Last post2011-11-15 14:39 -0500
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 David Riley <fraveydank@gmail.com> - 2011-11-15 14:39 -0500

#15734 — Re: suppressing import errors

FromDavid Riley <fraveydank@gmail.com>
Date2011-11-15 14:39 -0500
SubjectRe: suppressing import errors
Message-ID<mailman.2744.1321385952.27778.python-list@python.org>
On Nov 15, 2011, at 1:58 PM, Jean-Michel Pichavant wrote:

> PS : @Dave there is a way to avoiding adding symbols to your global namespace, assign None to the module's name on import errors. Then before using it, just test the module bool value : if serial: serial.whateverMethod()

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").

- Dave

[toc] | [standalone]


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


csiph-web