ID EN
Pretty Print

saferepr

Python 3.11

Return a string representation of object, protected against recursive data structures. If the representation of object exposes a recursive entry, the recursive reference will be represented as . The representation is not otherwise formatted.

Syntax

PYTHON
pprint.saferepr(object)

Examples

Example 1
PYTHON
>>> pprint.saferepr(stuff)
"[<Recursion on list with id=...>, 'spam', 'eggs', 'lumberjack', 'knights', 'ni']"