#NEWLINE# def getattrd( obj , name , default = sentinel ) : #NEWLINE# #INDENT# '\n    Same as getattr(), but allows dot notation lookup\n    Source: http://stackoverflow.com/a/14324459\n    ' #NEWLINE# try : #NEWLINE# #INDENT# return functools . reduce ( getattr , name . split ( '.' ) , obj ) #NEWLINE# #UNINDENT# except AttributeError as e : #NEWLINE# #INDENT# if ( default is not sentinel ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# raise