Dictionaries are fun and useful!. But just like a folder structure, they can be multitiered storing all kinds of things in nested hierarchies. tree
is a Linux utility that prints the multilevel structure of directories as a beautiful tree. dtree
does the same but for dictionaries.
Consider the following dictionary
dictionary = { "A": { "B": { "C": 0, "D": "some-string" }, "E": None }, "F": { "G": 0.0, "H": set([]) } }
Using dtree
you can print the tree structure in different ways:
This utility can be installed directly from PyPI as:
pip install dtree-metalcycling
For local installations intended for development, from the top of this repository run:
pip install -e .
This version currenly prints the str
representation of the dictionary keys for the nodes of the tree. When keys are custom class objects, printing them could be very verbose so that would cause issues with the printed tree. I'll fix this in future PRs.