#NEWLINE# def flatten( dictOfdicts ) : #NEWLINE# #INDENT# '\n    Recursive function: transforms a dict with nested entries like\n    foo["a"]["b"]["c"] = 3\n    to one with tuple entries like\n    fooPrime[("a","b","c")] = 3\n    ' #NEWLINE# output = [ ] #NEWLINE# for ( key , value ) in dictOfdicts . iteritems ( ) : #NEWLINE# #INDENT# if isinstance ( value , dict ) : #NEWLINE# #INDENT# output . append ( [ key , value ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# children = flatten ( value ) #NEWLINE# for child in children : #NEWLINE# #INDENT# output . append ( [ ( ( key , ) + child [ 0 ] ) , child [ 1 ] ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return output