def merge(left, right):
merged = {}<EOL>left_keys = frozenset(left)<EOL>right_keys = frozenset(right)<EOL>for key in left_keys - right_keys:<EOL><INDENT>merged[key] = left[key]<EOL><DEDENT>for key in right_keys - left_keys:<EOL><INDENT>merged[key] = right[key]<EOL><DEDENT>for key in left_keys & right_keys:<EOL><INDENT>left_value = left[key]<EOL>right_value = right[key]<EOL>if (isinstance(left_value, Mapping) and<EOL>isinstance(right_value, Mapping)):  <EOL><INDENT>merged[key] = merge(left_value, right_value)<EOL><DEDENT>else:  <EOL><INDENT>merged[key] = right_value<EOL><DEDENT><DEDENT>return merged<EOL>
Merge two mappings objects together, combining overlapping Mappings,
and favoring right-values

left: The left Mapping object.
right: The right (favored) Mapping object.

NOTE: This is not commutative (merge(a,b) != merge(b,a)).