Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
ChainMap solution in Clear category for The Flat Dictionary by flpo
from collections import ChainMap
def flatten(d, path=[]):
if d and isinstance(d, dict):
return dict(ChainMap(*(flatten(v, path + [k]) for k, v in d.items())))
return {"/".join(path): d or ""}
March 20, 2018
Comments: