summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-04-02 05:08:35 (GMT)
committerFred Drake <fdrake@acm.org>2002-04-02 05:08:35 (GMT)
commitaee113d368ebad8a51386baa7c0aec056aca94d5 (patch)
tree9a81e154b2772284d823cd0df3f966faa59a93e2 /Doc/lib
parent4993c51b9436bc28126659519c362558fdcdd0d7 (diff)
downloadcpython-aee113d368ebad8a51386baa7c0aec056aca94d5.zip
cpython-aee113d368ebad8a51386baa7c0aec056aca94d5.tar.gz
cpython-aee113d368ebad8a51386baa7c0aec056aca94d5.tar.bz2
Add an experimental mechanism to support extending the pprint formatting.
Partly responds to SF bug #505152.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libpprint.tex23
1 files changed, 23 insertions, 0 deletions
diff --git a/Doc/lib/libpprint.tex b/Doc/lib/libpprint.tex
index 3ecc7bc..22ffd7b 100644
--- a/Doc/lib/libpprint.tex
+++ b/Doc/lib/libpprint.tex
@@ -173,3 +173,26 @@ this returns false.
\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}