Testing the availability of a module

Kevin Yuan farproc at gmail.com
Mon Dec 19 04:22:45 EST 2005


2005/12/19, Bo Peng <bpeng at rice.edu>:
>
> Dear list,
>
> Is there a better way than doing
>
> try:
>    import aModule
> except:
>    has_aModule = False
> else:
>    has_aModule = True
>
> The main concern here is that loading aModule is unnecessary (and may
> take time).
>
> If loading aModule is unnecessary, the best way is not loading it atall.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20051219/23ceac1e/attachment.html>


More information about the Python-list mailing list