spacepy.toolbox.dictree — SpacePy v0.1.5 Manual

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »

# spacepy.toolbox.dictree

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

  pretty print a dictionary tree

  Parameters: | in_dict : dict a complex dictionary (with substructures) verbose : boolean (optional) print more info spaces : string (optional) string will added for every line levels : integer (optional) number of levels to recurse through (True means all) attrs : boolean (optional) display information for attributes

  Examples

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

  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)
      +
      |____PI
      |____counts
      >>> 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.

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »