import importlib


def get_module_attr(attr):
    """
    Gets an attribute from a module referred to with dot notation.
    Ex: get_class_module('email.message.Message') would return the class
    Message from the module email.message.

    Positional arguments:
    attr -- the dot-separated module and attribute to return

    Example:
    >>> get_module_attr('email.message.Message')
    <class 'email.message.Message'>
    """
    split_attr = attr.split('.')
    module_name = '.'.join(split_attr[:-1])
    attr_name = split_attr[-1]

    mod = importlib.import_module(module_name)
    return getattr(mod, attr_name)