On this page
pprint.saferepr
Prev: pprint.PrettyPrinter | Up: pprint
Rel: pprint.isreadable, pprint.isrecursive, pprint.pformat, pprint.pp
Ref: docs.python.org — pprint.saferepr
Tags: #public #python3 #stdlib #pprint
Import
import pprint
from pprint import saferepr
Signature & Overview
pprint.saferepr(object)
Version of repr() which can handle recursive data structures.
Usage
import pprint
a: list = []
a.append(a)
assert "Recursion" in pprint.saferepr(a)
Gotchas
- Prevents
RecursionErroron cyclic containers (similar toreprlib).
REPL Inspect
from pprint import saferepr
help(saferepr)
Linked from
Related notes
- tuts/python3/stdlib_module/pprint/PrettyPrinter Linked here; links to this page; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/isreadable Linked here; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/isrecursive Linked here; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/pformat Linked here; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/pp Linked here; shared tags: #pprint, #stdlib
- tuts/python3/stdlib_module/pprint/pprint Linked here; 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