Hide
Writing an article is easy - try our reStructured Text demo Join Siafoo Now or Learn More

Pretty Prints a Tree of Dictionaries in Python Atom Feed 1

In Brief Probably something that does this already, but here is another one =P
# 's
1def printTree(tree, depth = 0):
2 if tree == None or len(tree) == 0:
3 print "\t" * depth, "-"
4 else:
5 for key, val in tree.items():
6 print "\t" * depth, key
7 printTree(val, depth+1)

Probably something that does this already, but here is another one =P

Comments

over 8 years ago (30 Jul 2008 at 11:32 PM) by Stou S.
I could have used this 10 minutes ago.