Part of bzrlib
Function | get_named_object | Get the Python object named by a given module and member name. |
Function | calc_parent_name | Determine the 'parent' of a given dotted module name and (optional) |
Get the Python object named by a given module and member name.
This is usually much more convenient than dealing with __import__ directly:
>>> doc = get_named_object('bzrlib.pyutils', 'get_named_object.__doc__') >>> doc.splitlines()[0] 'Get the Python object named by a given module and member name.'
Parameters | module_name | a module name, as would be found in sys.modules if the module is already imported. It may contain dots. e.g. 'sys' or 'os.path'. |
member_name | (optional) a name of an attribute in that module to return. It may contain dots. e.g. 'MyClass.some_method'. If not given, the named module will be returned instead. | |
Raises | ImportError or AttributeError. |