spacepy.toolbox.dictree(in_dict, verbose=False, spaces=None, levels=True, attrs=False, **kwargs)[source]

pretty print a dictionary tree


a complex dictionary (with substructures)

verboseboolean (optional)

print more info

spacesstring (optional)

string will added for every line

levelsinteger (optional)

number of levels to recurse through (True means all)

attrsboolean (optional)

display information for attributes


>>> import spacepy.toolbox as tb
>>> d = {'grade':{'level1':[4,5,6], 'level2':[2,3,4]}, 'name':['Mary', 'John', 'Chris']}
>>> tb.dictree(d)

More complicated example using a datamodel:

>>> from spacepy import datamodel
>>> counts = datamodel.dmarray([2,4,6], attrs={'units': 'cts/s'})
>>> data = {'counts': counts, 'PI': 'Dr Zog'}
>>> tb.dictree(data)
>>> tb.dictree(data, attrs=True, verbose=True)
|____PI (str [6])
|____counts (spacepy.datamodel.dmarray (3,))
    :|____units (str [5])

Attributes of, e.g., a CDF or a datamodel type object (obj.attrs) are denoted by a colon.