def dynamic_importer(name, class_name=None):
 try:
  (fp, pathname, description) = imp.find_module(name)
 except ImportError:
  print ('unable to locate module: ' + name)
  return (None, None)
 try:
  package = imp.load_module(name, fp, pathname, description)
 except Exception:
  raise
 if class_name:
  try:
   _class = imp.load_module(('%s.%s' % (name, class_name)), fp, pathname, description)
  except Exception:
   raise
  return (package, _class)
 else:
  return (package, None)

def dynamic_importer ( name , class_name = None ) : try : ( fp , pathname , description ) = imp . find_module ( name ) except ImportError : print ( 'unable to locate module: ' + name ) return ( None , None ) try : package = imp . load_module ( name , fp , pathname , description ) except Exception : raise if class_name : try : _class = imp . load_module ( ( '%s.%s' % ( name , class_name ) ) , fp , pathname , description ) except Exception : raise return ( package , _class ) else : return ( package , None )
dynamically imports modules / classes .