(import_path, ld=dict())
return obj
import a python object from an import path like:

        mypackage.module.func
        or
        mypackage.module.class
import a python object from an import path like:
import a python object from an import path like :
def load_obj_from_path(import_path, ld=dict()):
    """
    import a python object from an import path like:

        mypackage.module.func
        or
        mypackage.module.class

    """
    try:
        return importlib.import_module(import_path)
    except ImportError as err:
        log.debug("Import path was not a module."
                  " Perhaps it points to a python object...",
                  extra=dict(err_msg=err, import_path=import_path))
    log.debug(
        'attempting to load a python object from an import path',
        extra=dict(import_path=import_path, **ld))
    try:
        path, obj_name = import_path.rsplit('.', 1)
    except ValueError:
        _log_raise(
            ("import path needs at least 1 period in your import path."
             " An example import path is something like: module.obj"),
            extra=dict(import_path=import_path, **ld),
            exception_kls=ImportWarning)
    mod = importlib.import_module(path)
    try:
        obj = getattr(mod, obj_name)
    except AttributeError:
        _log_raise(
            ("object does not exist in given module."
             " Fix your import path."),
            extra=dict(import_path=import_path, obj_name=obj_name, **ld),
            exception_kls=ImportWarning)
    return obj
def load_obj_from_path ( import_path , ld = dict ( ) ) : try : return importlib . import_module ( import_path ) except ImportError as err : log . debug ( "Import path was not a module." " Perhaps it points to a python object..." , extra = dict ( err_msg = err , import_path = import_path ) ) log . debug ( 'attempting to load a python object from an import path' , extra = dict ( import_path = import_path , * * ld ) ) try : path , obj_name = import_path . rsplit ( '.' , 1 ) except ValueError : _log_raise ( ( "import path needs at least 1 period in your import path." " An example import path is something like: module.obj" ) , extra = dict ( import_path = import_path , * * ld ) , exception_kls = ImportWarning ) mod = importlib . import_module ( path ) try : obj = getattr ( mod , obj_name ) except AttributeError : _log_raise ( ( "object does not exist in given module." " Fix your import path." ) , extra = dict ( import_path = import_path , obj_name = obj_name , * * ld ) , exception_kls = ImportWarning ) return obj