def testImport(module_name):
 try:
  return testImport.cache[module_name]
 except KeyError:
  try:
   __import__(module_name)
  except ImportError:
   result = False
  else:
   result = True
 testImport.cache[module_name] = result
 return result

def testImport ( module_name ) : try : return testImport . cache [ module_name ] except KeyError : try : __import__ ( module_name ) except ImportError : result = False else : result = True testImport . cache [ module_name ] = result return result
tell wether a module can be imported .