Given a dictionary like so:
my_map = {\'a\': 1, \'b\': 2}
How can one invert this map to get:
inv_map = {1: \'a\', 2: \'b\'
If the values in my_map aren't unique:
my_map
inv_map = {} for k, v in my_map.iteritems(): inv_map[v] = inv_map.get(v, []) + [k]