def import_module(path):
    """
    Import a module given a dotted *path* in the
    form of ``.name(.name)*``, and returns the
    last module (unlike ``__import__`` which just
    returns the first module).

    :param path: The dotted path to the module.
    """
    mod = __import__(path, locals={}, globals={})
    for item in path.split('.')[1:]:
        try:
            mod = getattr(mod, item)
        except AttributeError:
            raise ImportError('No module named %s' % path)
    return mod
Import a module given a dotted *path* in the
    form of ``.name(.name)*``, and returns the
    last module (unlike ``__import__`` which just
    returns the first module).

    :param path: The dotted path to the module.