monty.pprint module

Pretty printing functions.

draw_tree(node, child_iter=<function <lambda>>, text_str=<function <lambda>>)[source]
Parameters
  • node – the root of the tree to be drawn,

  • child_iter – function that when called with a node, returns an iterable over all its children

  • text_str – turns a node into the text to be displayed in the tree.

The default implementations of these two arguments retrieve the children by accessing node.children and simply use str(node) to convert a node to a string. The resulting tree is drawn into a buffer and returned as a string.

Based on https://pypi.python.org/pypi/asciitree/

pprint_table(table, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, rstrip=False)[source]

Prints out a table of data, padded for alignment Each row must have the same number of columns.

Parameters
  • table – The table to print. A list of lists.

  • out – Output stream (file-like object)

  • rstrip – if True, trailing withespaces are removed from the entries.