Testing the availability of a module

Bo Peng bpeng at rice.edu
Mon Dec 19 09:52:08 CET 2005


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

Many thanks in advance.
Bo



More information about the Python-list mailing list