← All notes

Python reprlib: size-limited object representations

Answer: reprlib produces object representations with limits on the size of the resulting strings.

What the module provides

It is used in the Python debugger and may be useful in other contexts.

The module provides a class, an instance, and a function.

The Repr class adds size limits for different object types so representations do not run on too long.

Constructor keyword arguments set attributes on a Repr instance.

Limits, placeholders, and recursion

Default limits include maxlevel 6, maxlist 6, and maxstring 30.

The constructor can set fillvalue as a shortcut for a Repr attribute.

A recursive_repr decorator can detect recursive calls to a custom representation method and substitute a placeholder.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, reprlib — Alternate repr() implementation; CPython, reprlib documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, reprlib — Alternate repr() implementation; CPython, reprlib documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:8x4sy7dn

iinventedlight. 2026. "Python reprlib: size-limited object representations." iinventedlight Library, iil:note:8x4sy7dn, version of 2026-11-24. https://iinventedlight.com/library/notes/python-reprlib/. License: CC-BY-4.0.

@misc{iil_note_8x4sy7dn,
  author = {{iinventedlight}},
  title = {{Python reprlib: size-limited object representations}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/python-reprlib/},
  note = {Permanent ID iil:note:8x4sy7dn. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-reprlib.md.