@@ -4,7 +4,7 @@ \section{Standard Module \sectcode{pprint}}
44\stmodindex {pprint}
55\label {module-pprint }
66
7- The \code {pprint} module provides a capability to `` pretty-print''
7+ The \module {pprint} module provides a capability to `` pretty-print''
88arbitrary Python data structures in a form which can be used as input
99to the interpreter. If the formatted structures include objects which
1010are not fundamental Python types, the representation may not be
@@ -14,33 +14,33 @@ \section{Standard Module \sectcode{pprint}}
1414
1515The formatted representation keeps objects on a single line if it can,
1616and breaks them onto multiple lines if they don't fit within the
17- allowed width. Construct PrettyPrinter objects explicitly if you need
18- to adjust the width constraint.
17+ allowed width. Construct \class { PrettyPrinter} objects explicitly if
18+ you need to adjust the width constraint.
1919
20- The \code {pprint} module defines one class:
20+ The \module {pprint} module defines one class:
2121
2222\setindexsubitem {(in module pprint)}
2323
2424% First the implementation class:
2525
26- \begin {funcdesc }{PrettyPrinter}{...}
27- Construct a PrettyPrinter instance. This constructor understands
28- several keyword parameters. An output stream may be set using the
29- \var {stream} keyword; the only method used on the stream object is the
30- file protocol's \code {write()} method. If not specified, the
31- PrettyPrinter adopts \code {sys.stdout}. Three additional parameters
32- may be used to control the formatted representation. The keywords are
33- \var {indent}, \var {depth}, and \var {width}. The amount of indentation
34- added for each recursive level is specified by \var {indent}; the
35- default is one. Other values can cause output to look a little odd,
36- but can make nesting easier to spot. The number of levels which may
37- be printed is controlled by \var {depth}; if the data structure being
38- printed is too deep, the next contained level is replaced by
39- \samp {...}. By default, there is no constraint on the depth of the
40- objects being formatted. The desired output width is constrained
41- using the \var {width} parameter; the default is eighty characters. If
42- a structure cannot be formatted within the constrained width, a best
43- effort will be made.
26+ \begin {classdesc }{PrettyPrinter}{...}
27+ Construct a \class { PrettyPrinter} instance. This constructor
28+ understands several keyword parameters. An output stream may be set
29+ using the \var {stream} keyword; the only method used on the stream
30+ object is the file protocol's \method {write()} method. If not
31+ specified, the \class { PrettyPrinter} adopts \code {sys.stdout}. Three
32+ additional parameters may be used to control the formatted
33+ representation. The keywords are \var {indent}, \var {depth}, and
34+ \var {width}. The amount of indentation added for each recursive level
35+ is specified by \var {indent}; the default is one. Other values can
36+ cause output to look a little odd, but can make nesting easier to
37+ spot. The number of levels which may be printed is controlled by
38+ \var {depth}; if the data structure being printed is too deep, the next
39+ contained level is replaced by \samp {...}. By default, there is no
40+ constraint on the depth of the objects being formatted. The desired
41+ output width is constrained using the \var {width} parameter; the
42+ default is eighty characters. If a structure cannot be formatted
43+ within the constrained width, a best effort will be made.
4444
4545\begin {verbatim }
4646>>> import pprint, sys
@@ -68,12 +68,12 @@ \section{Standard Module \sectcode{pprint}}
6868>>> pp.pprint(tup)
6969(266, (267, (307, (287, (288, (...))))))
7070\end {verbatim }
71- \end {funcdesc }
71+ \end {classdesc }
7272
7373
7474% Now the derivative functions:
7575
76- The PrettyPrinter class supports several derivative functions:
76+ The \class { PrettyPrinter} class supports several derivative functions:
7777
7878\begin {funcdesc }{pformat}{object}
7979Return the formatted representation of \var {object} as a string. The
@@ -84,8 +84,8 @@ \section{Standard Module \sectcode{pprint}}
8484Prints the formatted representation of \var {object} on \var {stream},
8585followed by a newline. If \var {stream} is omitted, \code {sys.stdout}
8686is used. This may be used in the interactive interpreter instead of a
87- \code {print} command for inspecting values. The default parameters
88- for formatting are used.
87+ \keyword {print} statement for inspecting values. The default
88+ parameters for formatting are used.
8989
9090\begin {verbatim }
9191>>> stuff = sys.path[:]
@@ -104,7 +104,8 @@ \section{Standard Module \sectcode{pprint}}
104104\begin {funcdesc }{isreadable}{object}
105105Determine if the formatted representation of \var {object} is
106106`` readable,'' or can be used to reconstruct the value using
107- \code {eval()}. Note that this returns false for recursive objects.
107+ \function {eval()}\bifuncindex {eval}. Note that this returns false for
108+ recursive objects.
108109
109110\begin {verbatim }
110111>>> pprint.isreadable(stuff)
@@ -136,15 +137,15 @@ \section{Standard Module \sectcode{pprint}}
136137
137138
138139\subsection {PrettyPrinter Objects }
140+ \label {PrettyPrinter Objects }
139141
140- PrettyPrinter instances (returned by \code {PrettyPrinter()} above)
141- have the following methods.
142+ PrettyPrinter instances have the following methods:
142143
143144\setindexsubitem {(PrettyPrinter method)}
144145
145146\begin {funcdesc }{pformat}{object}
146147Return the formatted representation of \var {object}. This takes into
147- account the options passed to the PrettyPrinter constructor.
148+ account the options passed to the \class { PrettyPrinter} constructor.
148149\end {funcdesc }
149150
150151\begin {funcdesc }{pprint}{object}
@@ -154,15 +155,16 @@ \subsection{PrettyPrinter Objects}
154155
155156The following methods provide the implementations for the
156157corresponding functions of the same names. Using these methods on an
157- instance is slightly more efficient since new PrettyPrinter objects
158- don't need to be created.
158+ instance is slightly more efficient since new \class { PrettyPrinter}
159+ objects don't need to be created.
159160
160161\begin {funcdesc }{isreadable}{object}
161162Determine if the formatted representation of the object is
162163`` readable,'' or can be used to reconstruct the value using
163- \code {eval()}. Note that this returns false for recursive objects.
164- If the \var {depth} parameter of the PrettyPrinter is set and the
165- object is deeper than allowed, this returns false.
164+ \function {eval()}\bifuncindex {eval}. Note that this returns false for
165+ recursive objects. If the \var {depth} parameter of the
166+ \class {PrettyPrinter} is set and the object is deeper than allowed,
167+ this returns false.
166168\end {funcdesc }
167169
168170\begin {funcdesc }{isrecursive}{object}
0 commit comments