import importlib


def class_from_name(class_path):
    """
    Instantiates a class from the given class path, consisting of a module path and the class name.

    :type class_path: unicode | str
    :return: type
    """
    module_name, __, class_name = class_path.rpartition('.')
    module = importlib.import_module(module_name)
    clazz = getattr(module, class_name)
    if not isinstance(clazz, type):
        raise AttributeError("Module '{0}' has no class '{1}'.", module_name, class_name)
    return clazz