#NEWLINE# def update_nested_dict( main_dict , new_dict ) : #NEWLINE# #INDENT# "Update nested dict (only level of nesting) with new values.\n\n\n    Unlike dict.update, this assumes that the values of the parent dict are\n    dicts, so you shouldn't replace the nested dict if it already exists.\n    Instead you should update the sub-dict.\n    " #NEWLINE# for ( name , rc_dict ) in new_dict . items ( ) : #NEWLINE# #INDENT# if ( name in main_dict ) : #NEWLINE# #INDENT# main_dict [ name ] . update ( rc_dict ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# main_dict [ name ] = rc_dict #NEWLINE# #UNINDENT# #UNINDENT# return main_dict