bff.idict

bff.idict(d)

Invert a dictionary.

Keys will be become values and values will become keys.

Parameters

d (dict of any to hashable) – Dictionary to invert.

Returns

Inverted dictionary.

Return type

dict of hashable to any

Raises

TypeError – If original values are not Hashable.

Examples

>>> idict({1: 4, 2: 5})
{4: 1, 5: 2}
>>> idict({1: 4, 2: 4, 3: 6})
{4: 2, 6: 3}