def load_obj_from_path(import_path, prefix=None, ld=dict()):
if prefix and not import_path.startswith(prefix):<EOL><INDENT>import_path = '<STR_LIT:.>'.join([prefix, import_path])<EOL><DEDENT>log.debug(<EOL>'<STR_LIT>',<EOL>extra=dict(import_path=import_path, **ld))<EOL>try:<EOL><INDENT>mod = importlib.import_module(import_path)<EOL>return mod  <EOL><DEDENT>except:<EOL><INDENT>pass  <EOL><DEDENT>try:<EOL><INDENT>path, obj_name = import_path.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>log_raise(<EOL>("<STR_LIT>"<EOL>"<STR_LIT>"),<EOL>dict(import_path=import_path, **ld), InvalidImportPath)<EOL><DEDENT>try:<EOL><INDENT>mod = importlib.import_module(path)<EOL><DEDENT>except ImportError:<EOL><INDENT>newpath = path.replace(prefix, '<STR_LIT>', <NUM_LIT:1>).lstrip('<STR_LIT:.>')<EOL>log.debug(<EOL>"<STR_LIT>",<EOL>extra=dict(oldpath=path, newpath=newpath))<EOL>path = newpath<EOL>mod = importlib.import_module(path)<EOL><DEDENT>try:<EOL><INDENT>obj = getattr(mod, obj_name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>log_raise(<EOL>("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"),<EOL>dict(import_path=path, obj_name=obj_name, **ld),<EOL>InvalidImportPath)<EOL><DEDENT>return obj<EOL>
import a python object from an import path

`import_path` - a python import path.  For instance:
        mypackage.module.func
    or
        mypackage.module.class
`prefix` (str) - a value to prepend to the import path
    if it isn't already there.  For instance:
        load_obj_from_path('module.func', prefix='mypackage')
    is the same as
        load_obj_from_path('mypackage.module.func')
`ld` (dict) key:value data to pass to the logger if an error occurs