def import_obj(clsname, default_module=None):
if default_module is not None:<EOL><INDENT>if not clsname.startswith(default_module + '<STR_LIT:.>'):<EOL><INDENT>clsname = '<STR_LIT>'.format(default_module, clsname)<EOL><DEDENT><DEDENT>mod, clsname = clsname.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL>mod = importlib.import_module(mod)<EOL>try:<EOL><INDENT>obj = getattr(mod, clsname)<EOL><DEDENT>except AttributeError:<EOL><INDENT>raise ImportError('<STR_LIT>'.format(clsname, mod))<EOL><DEDENT>return obj<EOL>
Import the object given by clsname.
If default_module is specified, import from this module.