def rec_getattr(obj, attr, default=None):
 try:
  return reduce(getattr, attr.split('.'), obj)
 except AttributeError:
  return default

def rec_getattr ( obj , attr , default = None ) : try : return reduce ( getattr , attr . split ( '.' ) , obj ) except AttributeError : return default
recursive getattr .