from functools import reduce
import operator


def dict_path(dictionary, path):
    """ Gets the value of the given dictionary at the given path. For example:

        >>> data = {'foo': {'bar': True}}
        >>> dict_path(data, 'foo.bar')
        True

    """

    if not dictionary:
        raise KeyError()

    return reduce(operator.getitem, path.split('.'), dictionary)