def get_module(plugin):
    """Turn a python module path into a module object.

    .. doctest::

       >>> import pysettings
       >>> pysettings == get_module('pysettings')
       True
       >>> pysettings.modules == get_module('pysettings.modules')
       True
       >>> get_module('pysettings.noexist')
       Traceback (most recent call last):
       ImportError: No module named noexist

    """
    try:
        modules = plugin.split('.')
        mod = __import__(plugin, {}, {}, [])
        for module in modules[1:]:
            mod = getattr(mod, module)
        return mod
    except ImportError:
        raise
