Fun transformation problem

Jonathan Wright quaggy at gmail.com
Fri Aug 27 00:39:02 EDT 2004


.def trans(paths):
.    tree = {}
.    for path in paths:
.        reduce(lambda branch,node: branch.setdefault(node,{}),
path[:-2], tree)[path[-2]] = path[-1]
.    return tree

Also seems to work. ;-)

Jonathan.




More information about the Python-list mailing list