pprint.pprint()

pprint.pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False)

Prints the formatted representation of object on stream, followed by a newline. If stream is None, sys.stdout is used. This may be used in the interactive interpreter instead of the print() function for inspecting values (you can even reassign print = pprint.pprint for use within a scope). indent, width, depth and compact will be passed to the PrettyPrinter constructor as formatting parameters.

Changed in version 3.4: Added the compact parameter.

>>> import pprint
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
>>> stuff.insert(0, stuff)
>>> pprint.pprint(stuff)
[<Recursion on list with id=...>,
 'spam',
 'eggs',
 'lumberjack',
 'knights',
 'ni']
doc_python
2016-10-07 17:40:55
Comments
Leave a Comment

Please login to continue.