konrad.utils.prefix_dict_keys

konrad.utils.prefix_dict_keys(dictionary, prefix, delimiter='/')[source]

Return a copy of a dictionary with a prefix added to every key.

Parameters
  • dictionary (dict) – Input dictionary.

  • prefix (str) – Prefix to add to every key.

  • delimiter (str) – String used to separate prefix and original key.

Returns

dict

Example

>>> prefix_dict_keys({'bar': 42}, prefix='foo', delimiter='.')
{'foo.bar': 42}