PyDocs

Nav

Data Types

recursive_repr

reprlib

decorator · Added in 3.2 (source)
  • @recursive_repr(fillvalue='...')
Decorator to make a repr function return fillvalue for a recursive call
1 Example
>>> from reprlib import recursive_repr
>>> class MyList(list):
...     @recursive_repr()
...     def __repr__(self):
...         return '<' + '|'.join(map(repr, self)) + '>'
...
>>> m = MyList('abc')
>>> m.append(m)
>>> m.append('x')
>>> print(m)
<'a'|'b'|'c'|...|'x'>
from the Python docs
See Also
No see-alsos for reprlib/recursive_repr
0 Notes
No notes for recursive_repr