pprint.pprint()
pprint.pprint() is a Python function in the Pprint Module category. Pretty-prints a Python object with proper indentation. The syntax is pprint.pprint(object, stream=None, indent=1, width=80, depth=None, *, compact=False, sort_dicts=True, underscore_numbers=False). Parameters: object, stream, indent. Returns: None. A typical example: import pprint
data = {"users": [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]}
pprint.pprint(data, depth=2, indent=2). A close sibling is pprint.pformat(), which same as pprint() but returns the formatted string instead of printing. A close sibling is pprint.PrettyPrinter(), which creates a PrettyPrinter instance for repeated use. More about this category: Pretty printer — pprint, pformat for readable output. Related Pprint Module entries: pprint.pformat(), pprint.PrettyPrinter(). 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.pprint() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.