Python reprlib Module
Example
Safely represent a large list without printing all elements:
import reprlib
large_list = list(range(100))
print(reprlib.repr(large_list))
Try it Yourself »
Definition and Usage
The reprlib module provides a way to produce safe string representations of objects with size limits.
Use it to prevent excessively long output when displaying large or deeply nested data structures like lists, dicts, or recursive objects.
Members
Member | Description |
---|---|
Repr | Class for customizing representation limits for different object types. |
aRepr | Instance of Repr used by the repr() function. |
recursive_repr() | Decorator to detect and handle recursive __repr__() calls. |
repr() | Return a size-limited string representation of an object. |