philistine.invert_dict

philistine.invert_dict(d)[source]

Return an ‘inverted’ dictionary, swapping keys against values.

Parameters:d (dict-like) – The dictionary to invert
Returns:inv_d – The inverted dictionary.
Return type:dict()

Notes

If the key-mapping is not one-to-one, then the dictionary is not invertible and a ValueError is thrown.