Python - How to update a multi-dimensional dict
<p>Follow up of my previous question: <a href="http://stackoverflow.com/questions/3680464/python-how-to-recursively-add-a-folders-content-in-a-dict">http://stackoverflow.com/questions/3680464/python-how-to-recursively-add-a-folders-content-in-a-dict</a>.</p>

<p>When I build the information dict for each file and folder, I need to merge it to the main tree dict.  The only way I have found so far is the write the dict as a text string and have it interpreted into a dict object and then merge it.  The issue is that the root object is always the same so it gets overwritten by the new dict and I lose the content.</p>

<pre><code>def recurseItem(Files, Item):
    global Settings
    ROOT = Settings['path']
    dbg(70, "Scanning " + Item)
    indices = path2indice(Item)
    ItemAnalysis = Analyse(Item)
    Treedict = ""#{'" + ROOT + "': "
    i=0
    for indice in indices:
        Treedict = Treedict + "{'" + indice + "': "
        i=i+1
    Treedict = Treedict + repr(ItemAnalysis)
    while i&gt;0:
        Treedict = Treedict + "}"
        i=i-1
    Files = dict(Files.items() + Treedict.items())
return Files
</code></pre>

<p>Is there a way to avoid the messy indices construct (i.e. Files[ROOT][fileName][fileName2][fileName3][fileName4] ) which can't be generated on the fly?  I need to be able to update a key's content without overwriting the root key.  Any idea would be much welcomed !</p>
