def for_name(fq_name, recursive=False):
 fq_name = str(fq_name)
 module_name = __name__
 short_name = fq_name
 if (fq_name.rfind('.') >= 0):
  (module_name, short_name) = (fq_name[:fq_name.rfind('.')], fq_name[(fq_name.rfind('.') + 1):])
 try:
  result = __import__(module_name, None, None, [short_name])
  return result.__dict__[short_name]
 except KeyError:
  if recursive:
   raise
  else:
   raise ImportError(("Could not find '%s' on path '%s'" % (short_name, module_name)))
 except ImportError:
  try:
   module = for_name(module_name, recursive=True)
   if hasattr(module, short_name):
    return getattr(module, short_name)
   else:
    raise KeyError()
  except KeyError:
   raise ImportError(("Could not find '%s' on path '%s'" % (short_name, module_name)))
  except ImportError:
   pass
  raise

def for_name ( fq_name , recursive = False ) : fq_name = str ( fq_name ) module_name = __name__ short_name = fq_name if ( fq_name . rfind ( '.' ) >= 0 ) : ( module_name , short_name ) = ( fq_name [ : fq_name . rfind ( '.' ) ] , fq_name [ ( fq_name . rfind ( '.' ) + 1 ) : ] ) try : result = __import__ ( module_name , None , None , [ short_name ] ) return result . __dict__ [ short_name ] except KeyError : if recursive : raise else : raise ImportError ( ( "Could not find '%s' on path '%s'" % ( short_name , module_name ) ) ) except ImportError : try : module = for_name ( module_name , recursive = True ) if hasattr ( module , short_name ) : return getattr ( module , short_name ) else : raise KeyError ( ) except KeyError : raise ImportError ( ( "Could not find '%s' on path '%s'" % ( short_name , module_name ) ) ) except ImportError : pass raise
find class/function/method specified by its fully qualified name .