def fuzzy_import_from_module(path, variable, default=None, defaultpaths=None):
 paths = ([path] + make_iter(defaultpaths))
 for modpath in paths:
  try:
   mod = import_module(path)
  except ImportError as ex:
   if (not str(ex).startswith(('No module named %s' % path))):
    raise ex
   return getattr(mod, variable, default)
 return default

def fuzzy_import_from_module ( path , variable , default = None , defaultpaths = None ) : paths = ( [ path ] + make_iter ( defaultpaths ) ) for modpath in paths : try : mod = import_module ( path ) except ImportError as ex : if ( not str ( ex ) . startswith ( ( 'No module named %s' % path ) ) ) : raise ex return getattr ( mod , variable , default ) return default
import a variable based on a fuzzy path .