import importlib


def str2class(value):
    """
    From import path string, returns the class specified.

    For example, the string 'parlai.agents.drqa.drqa:SimpleDictionaryAgent'
    returns <class 'parlai.agents.drqa.drqa.SimpleDictionaryAgent'>.
    """
    if ':' not in value:
        raise RuntimeError('Use a colon before the name of the class.')
    name = value.split(':')
    module = importlib.import_module(name[0])
    return getattr(module, name[1])