[Python-checkins] CVS: python/dist/src/Doc/lib libpprint.tex,1.14,1.15

Fred L. Drake fdrake@users.sourceforge.net
Mon, 01 Apr 2002 21:08:38 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv16772/Doc/lib

Modified Files:
	libpprint.tex 
Log Message:
Add an experimental mechanism to support extending the pprint formatting.
Partly responds to SF bug #505152.


Index: libpprint.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libpprint.tex,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** libpprint.tex	10 Oct 2000 17:03:45 -0000	1.14
--- libpprint.tex	2 Apr 2002 05:08:35 -0000	1.15
***************
*** 174,175 ****
--- 174,198 ----
  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}