reprlib
— 替代
repr()
实现
¶
源代码: Lib/reprlib.py
The
reprlib
module provides a means for producing object representations with limits on the size of the resulting strings. This is used in the Python debugger and may be useful in other contexts as well.
This module provides a class, an instance, and a function:
- class reprlib. Repr ( * , maxlevel = 6 , maxtuple = 6 , maxlist = 6 , maxarray = 5 , maxdict = 4 , maxset = 6 , maxfrozenset = 6 , maxdeque = 6 , maxstring = 30 , maxlong = 40 , maxother = 30 , fillvalue = '...' , indent = None ) ¶
-
Class which provides formatting services useful in implementing functions similar to the built-in
repr(); size limits for different object types are added to avoid the generation of representations which are excessively long.The keyword arguments of the constructor can be used as a shortcut to set the attributes of the
Reprinstance. Which means that the following initialization:aRepr = reprlib.Repr(maxlevel=3)