pprint.PrettyPrinter()
pprint.PrettyPrinter() is a Python function in the Pprint Module category. Creates a PrettyPrinter instance for repeated use. The syntax is pprint.PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, compact=False, sort_dicts=True, underscore_numbers=False). Returns: PrettyPrinter object. A typical example: pp = pprint.PrettyPrinter(indent=2, width=40)
pp.pprint(data). A close sibling is pprint.pprint(), which pretty-prints a Python object with proper indentation. A close sibling is pprint.pformat(), which same as pprint() but returns the formatted string instead of printing. More about this category: Pretty printer — pprint, pformat for readable output. Related Pprint Module entries: pprint.pprint(), pprint.pformat(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try pprint.PrettyPrinter() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.