dict_inv

hhpy.main.dict_inv(dct: Mapping[KT, VT_co], key_as_str: bool = False, duplicates: str = 'keep') → dict[source]

Returns an inverted copy of a given dictionary (if it is invertible)

Parameters:
  • dct – Dictionary to be inverted
  • key_as_str – Whether all keys of the inverted dictionary should be forced to string
  • duplicates – Whether to ‘adjust’ or ‘drop’ duplicates. In case of ‘adjust’ duplicates are suffixed with ‘_’
Returns:

Inverted dictionary