question about tree in python

Lie Ryan lie.1296 at gmail.com
Wed Nov 18 17:01:21 EST 2009


nospam wrote:
> How should I write a tree using diconary. I have used a dictonary to 
> make a tree.

dictionary tree?

root = {
     'node_a': {
         'node_a_a': 'blah',
         'node_a_b': 'foo',
         'node_a_c': 'bar',
     },
     'node_b': {
         'node_b_a': 'soo',
         'node_b_b': 'flee',
         'node_b_c': {
             'node_b_c_a': 'bee',
             'node_b_c_b': 'fee',
             'node_b_c_c': 'dee',
         },
     },
}

you can throw in some default dicts as well as necessary...

Am I misunderstanding something?



More information about the Python-list mailing list