Category tree of some sort ...

Thomas Weholt 2002 at weholt.org
Fri Dec 6 18:58:26 EST 2002


I got a bunch of content categories in form of a list of lists :

categories = [
        ['computers','programming','python'],
        ['computers','programming','c'],
        ['computers','technical','os']
]

I need to put this into a tree-structure, a dictionary like this :

category_tree = {
    'computers': ([], {
        'programming': ([], {
            'python': ( [], {}),
            'c': ( [], {}),
        },
    'technical': ([], {
        'os': ([], {}),
        }
    }

Each level holds a list of ids, pointing to resources on a local disk, the
dict-part of each tuple is the base for a another, deeper level in the
tree-structure.

If anybody has any other idea on how to effectivly storing information about
files where the folders are names of categories and each file is assigned a
uniq id for look-up, please let me know.

Thanks,
Thomas





More information about the Python-list mailing list