Skip to content

Instantly share code, notes, and snippets.

Created November 8, 2012 16:01
Show Gist options
  • Save anonymous/4039718 to your computer and use it in GitHub Desktop.
Save anonymous/4039718 to your computer and use it in GitHub Desktop.
def flatten(d, parent_key=''):
items = []
for k, v in d.items():
new_key = parent_key + '//' + k if parent_key else k
if isinstance(v, collections.MutableMapping):
items.extend(flatten(v, new_key).items())
else:
items.append((new_key, v))
return dict(items)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment