def getattrdeep(obj, attr, *default):
    'Return dotted attr (like "a.b.c") from obj, or default if any of the components are missing.'
    attrs = attr.split('.')
    if default:
        getattr_default = lambda o,a,d=default[0]: getattr(o, a, d)
    else:
        getattr_default = lambda o,a: getattr(o, a)

    for a in attrs[:-1]:
        obj = getattr_default(obj, a)

    return getattr_default(obj, attrs[-1])
def getattrdeep ( obj , attr , * default ) : attrs = attr . split ( '.' ) if default : getattr_default = lambda o , a , d = default [ 0 ] : getattr ( o , a , d ) else : getattr_default = lambda o , a : getattr ( o , a ) for a in attrs [ : - 1 ] : obj = getattr_default ( obj , a ) return getattr_default ( obj , attrs [ - 1 ] )
Return dotted attr (like "a.b.c") from obj, or default if any of the components are missing.