spiketools.utils.base.add_key_prefix

spiketools.utils.base.add_key_prefix(indict, prefix)[source]

Update keys of a dictionary by appending a prefix.

Parameters:
indictdict

Dictionary to update keys for.

prefixstr

Prefix to add to each dictionary key.

Returns:
dict

Dictionary with updated keys.

Examples

Add a prefix to dictionary keys:

>>> indict = {'setting' : 12, 'param' : 22}
>>> add_key_prefix(indict, 'analysis')
{'analysis_setting': 12, 'analysis_param': 22}