Last active
December 14, 2015 01:39
-
-
Save mastier/5007831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# useful way to flatten dictionary representing i.e. path to file and content | |
# now fixed in case of running it again | |
def flatten_dict(d,path=(),paths=None, sep='/'): | |
if paths==None: paths=[] | |
if isinstance(d,dict): | |
for k,v in d.items(): | |
flatten_dict(v,path+(k,),paths) | |
return paths | |
else: | |
paths.append( { sep+sep.join(path) : d } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment