How to test if a module exists?
Jon Dufresne
jon.dufresne at gmail.com
Sat Nov 6 21:57:36 EDT 2010
On Sat, Nov 6, 2010 at 1:52 PM, Roy Smith <roy at panix.com> wrote:
>
> import sys
> try:
> import xx
> except ImportError:
> tb = sys.exc_traceback
> while tb:
> print tb
> tb = tb.tb_next
>
I went ahead and implemented this and it now works. I even uncovered a
bug I wasn't previously seeing because now the program was failing
early! :)
I hope there isn't a hidden naivete in using this pattern.
Thanks,
Jon
More information about the Python-list
mailing list