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
- id: C1 claim: reprlib can produce object representations with size limits. source: S1 evidence: "producing object representations with limits on the size of the resulting strings"
- id: C2 claim: The module provides a class, an instance, and a function. source: S1 evidence: "This module provides a class, an instance, and a function"
- id: C3 claim: reprlib can produce object representations with size limits. source: S2 evidence: "producing object representations with limits on the size of the resulting strings"
- id: C4 claim: The module provides a class, an instance, and a function. source: S2 evidence: "This module provides a class, an instance, and a function"
Sources
- [S1] reprlib — Alternate repr() implementation. Python Software Foundation. https://docs.python.org/3/library/reprlib.html . License: PSF License Version 2. Accessed 2026-11-24.
- [S2] reprlib documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/reprlib.rst . License: PSF License Version 2. Accessed 2026-11-24.
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
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.},
}
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.
- python-reprlib.schema.json (schema; CC-BY-4.0)
- python-reprlib.table.json (table; CC-BY-4.0)
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.