b.pyutils : module documentation

Part of bzrlib

General Python convenience functions.
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)
def get_named_object(module_name, member_name=None):

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.'
Parametersmodule_namea 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.
RaisesImportError or AttributeError.
def calc_parent_name(module_name, member_name=None):
Determine the 'parent' of a given dotted module name and (optional) member name.

The idea is that getattr(parent_obj, final_attr) will equal get_named_object(module_name, member_name).

Returns(module_name, member_name, final_attr) tuple.
API Documentation for Bazaar, generated by pydoctor at 2019-04-21 00:18:09.