Skip to content

Instantly share code, notes, and snippets.

@marksweissma
marksweissma / unpack_dict.py
Created July 20, 2017 00:46
unpack nested dicts by concatenating keys
def unpack_dict(d, keys=None, passed=None, filterNone=True):
"""
Unpack nested dictionary with _ separted keys
:param dict d: nested dictionary to unpack
:param list keys: sequence of access keys
:param dict passed: dict to update with flattened keys
:param bool filterNone: filter out keys where value is None
:return: flattened dict
:rtype: dict