pprint.PrettyPrinter.pprint()

PrettyPrinter.pprint(object) Print the formatted representation of object on the configured stream, followed by a newline.

pprint.PrettyPrinter.pformat()

PrettyPrinter.pformat(object) Return the formatted representation of object. This takes into account the options passed to the PrettyPrinter constructor.

pprint.PrettyPrinter.isrecursive()

PrettyPrinter.isrecursive(object) Determine if the object requires a recursive representation.

pprint.PrettyPrinter.isreadable()

PrettyPrinter.isreadable(object) Determine if the formatted representation of the object is “readable,” or can be used to reconstruct the value using eval(). Note that this returns False for recursive objects. If the depth parameter of the PrettyPrinter is set and the object is deeper than allowed, this returns False.

pprint.PrettyPrinter.format()

PrettyPrinter.format(object, context, maxlevels, level) Returns three values: the formatted version of object as a string, a flag indicating whether the result is readable, and a flag indicating whether recursion was detected. The first argument is the object to be presented. The second is a dictionary which contains the id() of objects that are part of the current presentation context (direct and indirect containers for object that are affecting the presentation) as the keys; if an object n

pprint.PrettyPrinter

class pprint.PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, compact=False) Construct a PrettyPrinter instance. This constructor understands several keyword parameters. An output stream may be set using the stream keyword; the only method used on the stream object is the file protocol’s write() method. If not specified, the PrettyPrinter adopts sys.stdout. The amount of indentation added for each recursive level is specified by indent; the default is one. Other values can cause

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 v

pprint.pformat()

pprint.pformat(object, indent=1, width=80, depth=None, *, compact=False) Return the formatted representation of object as a string. indent, width, depth and compact will be passed to the PrettyPrinter constructor as formatting parameters. Changed in version 3.4: Added the compact parameter.

pprint.isrecursive()

pprint.isrecursive(object) Determine if object requires a recursive representation.

pprint.isreadable()

pprint.isreadable(object) Determine if the formatted representation of object is “readable,” or can be used to reconstruct the value using eval(). This always returns False for recursive objects. >>> pprint.isreadable(stuff) False