Mercurial > cpython-lru_cache-weakref
diff Doc/lib/libpprint.tex @ 22766:d26d8575ac62 legacy-trunk
Add an experimental mechanism to support extending the pprint formatting.
Partly responds to SF bug #505152.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 02 Apr 2002 05:08:35 +0000 |
| parents | 563dee598d3a |
| children | f967589df751 |
line wrap: on
line diff
--- a/Doc/lib/libpprint.tex Mon Apr 01 23:56:03 2002 +0000 +++ b/Doc/lib/libpprint.tex Tue Apr 02 05:08:35 2002 +0000 @@ -173,3 +173,26 @@ \begin{methoddesc}{isrecursive}{object} Determine if the object requires a recursive representation. \end{methoddesc} + +This method is provided as a hook to allow subclasses to modify the +way objects are converted to strings. The default implementation uses +the internals of the \function{saferepr()} implementation. + +\begin{methoddesc}{format}{object, context, maxlevels, level} +Returns three values: the formatted version of \var{object} as a +string, a flag indicating whether the result is readable, and a flag +indicating whether recursion was detected. The first argument is the +object to be presented. The second is a dictionary which contains the +\function{id()} of objects that are part of the current presentation +context (direct and indirect containers for \var{object} that are +affecting the presentation) as the keys; if an object needs to be +presented which is already represented in \var{context}, the third +return value should be true. Recursive calls to the \method{format()} +method should add additionaly entries for containers to this +dictionary. The fourth argument, \var{maxlevels}, gives the requested +limit to recursion; this will be \code{0} if there is no requested +limit. This argument should be passed unmodified to recursive calls. +The fourth argument, \var{level} gives the current level; recursive +calls should be passed a value less than that of the current call. +\versionadded{2.3} +\end{methoddesc}
