import importlib


def get_module_element_from_path(opath):
    """ Retrieve an element from a python module using its path <package>.<module>.<object>.

    This can be for example a global function or a class.

    Args:
        opath:  Object path
    Returns:
        Module object
    """
    module, oname = opath.rsplit('.', 1)
    mod = importlib.import_module(module)
    return getattr(mod, oname)