On this page
pprint.pp
Prev: pprint.pformat | Up: pprint | Next: pprint.pprint
Rel: pprint.isreadable, pprint.isrecursive, pprint.pformat, pprint.pprint
Ref: docs.python.org — pprint.pp
Tags: #public #python3 #stdlib #pprint
Import
import pprint
from pprint import pp
Signature & Overview
pprint.pp(object, *args, sort_dicts=False, **kwargs)
Pretty-print a Python object
Usage
import io
import pprint
buf = io.StringIO()
pprint.pp({"z": 1, "a": 2}, stream=buf)
assert buf.getvalue().index("'z'") < buf.getvalue().index("'a'")
Gotchas
- Like
pprint(), but defaults tosort_dicts=Falseso dict insertion order is preserved.
REPL Inspect
from pprint import pp
help(pp)
Linked from
Related notes
- tuts/python3/stdlib_module/pprint/isreadable Linked here; links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/isrecursive Linked here; links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/pformat Linked here; links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/pprint Linked here; links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/PrettyPrinter links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/saferepr links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib