Skip to content

Instantly share code, notes, and snippets.

@mnebuerquo
Created January 19, 2018 15:50
Show Gist options
  • Save mnebuerquo/09587fb8cba781bfeb95f0323fe775b8 to your computer and use it in GitHub Desktop.
Save mnebuerquo/09587fb8cba781bfeb95f0323fe775b8 to your computer and use it in GitHub Desktop.
code I ripped off from someone on stack overflow
# https://stackoverflow.com/a/19647596/5114
def flatten_dict(dd, separator='_', prefix=''):
return { prefix + separator + k if prefix else k : v
for kk, vv in dd.items()
for k, v in flatten_dict(vv, separator, kk).items()
} if isinstance(dd, dict) else { prefix : dd }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment