def compare_dicts(dict1, dict2, dict1_name, dict2_name):
 dict1_keyset = set(dict1.keys())
 dict2_keyset = set(dict2.keys())
 print_key_diff((dict1_keyset - dict2_keyset), dict1_name, dict2_name)
 print_key_diff((dict2_keyset - dict1_keyset), dict2_name, dict1_name)
 print 'Value differences:'
 has_value_differences = False
 for key in (dict1_keyset & dict2_keyset):
  if (dict1[key] != dict2[key]):
   print ('  %s:' % (key,))
   print ('    %s: %s' % (dict1_name, dict1[key]))
   print ('    %s: %s' % (dict2_name, dict2[key]))
   print
   has_value_differences = True
 if (not has_value_differences):
  print '  None'

def compare_dicts ( dict1 , dict2 , dict1_name , dict2_name ) : dict1_keyset = set ( dict1 . keys ( ) ) dict2_keyset = set ( dict2 . keys ( ) ) print_key_diff ( ( dict1_keyset - dict2_keyset ) , dict1_name , dict2_name ) print_key_diff ( ( dict2_keyset - dict1_keyset ) , dict2_name , dict1_name ) print 'Value differences:' has_value_differences = False for key in ( dict1_keyset & dict2_keyset ) : if ( dict1 [ key ] != dict2 [ key ] ) : print ( '  %s:' % ( key , ) ) print ( '    %s: %s' % ( dict1_name , dict1 [ key ] ) ) print ( '    %s: %s' % ( dict2_name , dict2 [ key ] ) ) print has_value_differences = True if ( not has_value_differences ) : print '  None'
compare the two dictionaries .