On this page
  1. reprlib.recursive_repr
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from reprlib import recursive_repr
help(recursive_repr)

Linked from

Related notes