How to test if a module exists?
jon.dufresne at gmail.com
Sat Nov 6 19:50:35 CET 2010
On Sat, Nov 6, 2010 at 11:35 AM, Chris Rebert <clp2 at rebertia.com> wrote:
> Here's what I came up with:
> import extension_magic_module
> except ImportError as err:
> if err.message != "No module named extension_magic_module":
> raise err
It seems less than ideal to tie my program's behavior to what
essentially boils down to a documentation string. Is this the
preferred way to handle this?
More information about the Python-list