def map_dict_keys(dict_, key_map):
 mapped = {}
 for (key, value) in dict_.iteritems():
  mapped_key = (key_map[key] if (key in key_map) else key)
  mapped[mapped_key] = value
 return mapped

def map_dict_keys ( dict_ , key_map ) : mapped = { } for ( key , value ) in dict_ . iteritems ( ) : mapped_key = ( key_map [ key ] if ( key in key_map ) else key ) mapped [ mapped_key ] = value return mapped
return a dict in which the dictionaries keys are mapped to new keys .