import functools


def dgetattr(obj, name, is_dict=False):
    """
    get deep attribute
    operates the same as getattr(obj, name) but can use '.' for nested attributes
    e.g. dgetattr(my_object, 'a.b') would return value of my_object.a.b
    """
    atr = dict.__getitem__ if is_dict else getattr
    names = name.split('.')
    names = [obj] + names
    return functools.reduce(atr, names)