On this page
reprlib.recursive_repr
Up: reprlib | Next: reprlib.repr
Rel: reprlib.repr, reprlib.Repr
Ref: docs.python.org — reprlib.recursive_repr
Tags: #public #python3 #stdlib #reprlib
Import
import reprlib
from reprlib import recursive_repr
Signature & Overview
reprlib.recursive_repr(fillvalue='...')
Decorator to make a repr function return fillvalue for a recursive call
Usage
import reprlib
class Box:
def __init__(self): self.items = []
@reprlib.recursive_repr()
def __repr__(self): return f'Box({self.items!r})'
b = Box(); b.items.append(b)
assert repr(b) == 'Box([...])'
Gotchas
- Prevents
RecursionErrorin custom container__repr__methods.
REPL Inspect
from reprlib import recursive_repr
help(recursive_repr)
Linked from
Related notes
- tuts/python3/stdlib_module/reprlib/repr Linked here; links to this page; shared tags: #reprlib, #stdlib
- tuts/python3/stdlib_module/reprlib/Repr_class Linked here; links to this page; shared tags: #reprlib, #stdlib
- tuts/python3/stdlib_module/reprlib Linked here; 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
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib