David Pratt <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]: 

> Hi. I am wanting to create a tree list result structure from a 
> dictionary to categorize results. The dictionary contains elements
> that identify its parent. The levels of categorization is not fixed,
> so there is a need for the code to be recursive to drill down to the
> lowest level. I have contrived a small source and result list to
> illustrate: 
> 
   
>>> imd=dict()
>>> for d in source_list:
        par=d['parent']
        v=d['title']
        try:
                imd[par].append(v)
        except:
                imd[par]=[v]

                
>>> imd
{'Project': ['Geometries', 'Verticals'], 'Geometry': ['Points',
'Layers', 'Water'], 'root': ['Project', 'Geometry', 'Soil'], 'Soil':
['Soiltypes']} 
>>> 

And then do whatever you need to do from here...

max

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to