annotate Doc/lib/libpprint.tex @ 7277:bf4e790bd61a legacy-trunk

Remove all \bcode / \ecode cruft; this is no longer needed. See previous checkin of myformat.sty. Change "\renewcommand{\indexsubitem}{(...)}" to "\setindexsubitem{(...)}" everywhere. Some other minor nits that I happened to come across.
author Fred Drake <fdrake@acm.org>
date Fri, 13 Feb 1998 06:58:54 +0000
parents adb300cbd566
children 11e9337cda3d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 %% Author: Fred L. Drake, Jr. <fdrake@acm.org>
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2
6901
adb300cbd566 Make the word "Module" in the section header start with an upper-case "M".
Fred Drake <fdrake@acm.org>
parents: 6647
diff changeset
3 \section{Standard Module \sectcode{pprint}}
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \stmodindex{pprint}
6901
adb300cbd566 Make the word "Module" in the section header start with an upper-case "M".
Fred Drake <fdrake@acm.org>
parents: 6647
diff changeset
5 \label{module-pprint}
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 The \code{pprint} module provides a capability to ``pretty-print''
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8 arbitrary Python data structures in a form which can be used as input
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9 to the interpreter. If the formatted structures include objects which
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10 are not fundamental Python types, the representation may not be
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11 loadable. This may be the case if objects such as files, sockets,
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 classes, or instances are included, as well as many other builtin
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 objects which are not representable as Python constants.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15 The formatted representation keeps objects on a single line if it can,
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
16 and breaks them onto multiple lines if they don't fit within the
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
17 allowed width. Construct PrettyPrinter objects explicitly if you need
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
18 to adjust the width constraint.
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
20 The \code{pprint} module defines one class:
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
21
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 6901
diff changeset
22 \setindexsubitem{(in module pprint)}
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
24 % First the implementation class:
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
25
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
26 \begin{funcdesc}{PrettyPrinter}{...}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
27 Construct a PrettyPrinter instance. This constructor understands
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
28 several keyword parameters. An output stream may be set using the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
29 \var{stream} keyword; the only method used on the stream object is the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
30 file protocol's \code{write()} method. If not specified, the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
31 PrettyPrinter adopts \code{sys.stdout}. Three additional parameters
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
32 may be used to control the formatted representation. The keywords are
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
33 \var{indent}, \var{depth}, and \var{width}. The amount of indentation
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
34 added for each recursive level is specified by \var{indent}; the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
35 default is one. Other values can cause output to look a little odd,
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
36 but can make nesting easier to spot. The number of levels which may
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
37 be printed is controlled by \var{depth}; if the data structure being
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
38 printed is too deep, the next contained level is replaced by
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
39 \samp{...}. By default, there is no constraint on the depth of the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
40 objects being formatted. The desired output width is constrained
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
41 using the \var{width} parameter; the default is eighty characters. If
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
42 a structure cannot be formatted within the constrained width, a best
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
43 effort will be made.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
44
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
45 \begin{verbatim}
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
46 >>> import pprint, sys
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47 >>> stuff = sys.path[:]
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
48 >>> stuff.insert(0, stuff[:])
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
49 >>> pp = pprint.PrettyPrinter(indent=4)
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 >>> pp.pprint(stuff)
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51 [ [ '',
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
52 '/usr/local/lib/python1.5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
53 '/usr/local/lib/python1.5/test',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
54 '/usr/local/lib/python1.5/sunos5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
55 '/usr/local/lib/python1.5/sharedmodules',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
56 '/usr/local/lib/python1.5/tkinter'],
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
57 '',
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
58 '/usr/local/lib/python1.5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
59 '/usr/local/lib/python1.5/test',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
60 '/usr/local/lib/python1.5/sunos5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
61 '/usr/local/lib/python1.5/sharedmodules',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
62 '/usr/local/lib/python1.5/tkinter']
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
63 >>>
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
64 >>> import parser
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
65 >>> tup = parser.ast2tuple(
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
66 ... parser.suite(open('pprint.py').read()))[1][1][1]
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
67 >>> pp = pprint.PrettyPrinter(depth=6)
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
68 >>> pp.pprint(tup)
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
69 (266, (267, (307, (287, (288, (...))))))
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
70 \end{verbatim}
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
71 \end{funcdesc}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
72
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
73
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
74 % Now the derivative functions:
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
75
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
76 The PrettyPrinter class supports several derivative functions:
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
77
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
78 \begin{funcdesc}{pformat}{object}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
79 Return the formatted representation of \var{object} as a string. The
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
80 default parameters for formatting are used.
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
81 \end{funcdesc}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
82
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
83 \begin{funcdesc}{pprint}{object\optional{, stream}}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
84 Prints the formatted representation of \var{object} on \var{stream},
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
85 followed by a newline. If \var{stream} is omitted, \code{sys.stdout}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
86 is used. This may be used in the interactive interpreter instead of a
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
87 \code{print} command for inspecting values. The default parameters
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
88 for formatting are used.
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
89
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
90 \begin{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
91 >>> stuff = sys.path[:]
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
92 >>> stuff.insert(0, stuff)
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
93 >>> pprint.pprint(stuff)
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
94 [<Recursion on list with id=869440>,
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
95 '',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
96 '/usr/local/lib/python1.5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
97 '/usr/local/lib/python1.5/test',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
98 '/usr/local/lib/python1.5/sunos5',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
99 '/usr/local/lib/python1.5/sharedmodules',
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
100 '/usr/local/lib/python1.5/tkinter']
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
101 \end{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
102 \end{funcdesc}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
103
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
104 \begin{funcdesc}{isreadable}{object}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
105 Determine if the formatted representation of \var{object} is
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
106 ``readable,'' or can be used to reconstruct the value using
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
107 \code{eval()}. Note that this returns false for recursive objects.
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
108
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
109 \begin{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
110 >>> pprint.isreadable(stuff)
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
111 0
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
112 \end{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
113 \end{funcdesc}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
114
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
115 \begin{funcdesc}{isrecursive}{object}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
116 Determine if \var{object} requires a recursive representation.
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
117 \end{funcdesc}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
118
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
119
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
120 One more support function is also defined:
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
121
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
122 \begin{funcdesc}{saferepr}{object}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
123 Return a string representation of \var{object}, protected against
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
124 recursive data structures. If the representation of \var{object}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
125 exposes a recursive entry, the recursive reference will be represented
6901
adb300cbd566 Make the word "Module" in the section header start with an upper-case "M".
Fred Drake <fdrake@acm.org>
parents: 6647
diff changeset
126 as \samp{<Recursion on \var{typename} with id=\var{number}>}. The
5896
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
127 representation is not otherwise formatted.
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
128
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
129 \begin{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
130 >>> pprint.saferepr(stuff)
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
131 "[<Recursion on list with id=682968>, '', '/usr/local/lib/python1.4', '/usr/loca
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
132 l/lib/python1.4/test', '/usr/local/lib/python1.4/sunos5', '/usr/local/lib/python
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
133 1.4/sharedmodules', '/usr/local/lib/python1.4/tkinter']"
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
134 \end{verbatim}
67022d28a65d A couple of grammatical nits.
Fred Drake <fdrake@acm.org>
parents: 5836
diff changeset
135 \end{funcdesc}
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
136
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
137
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
138 \subsection{PrettyPrinter Objects}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
139
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
140 PrettyPrinter instances (returned by \code{PrettyPrinter()} above)
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
141 have the following methods.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
142
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 6901
diff changeset
143 \setindexsubitem{(PrettyPrinter method)}
5836
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
144
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
145 \begin{funcdesc}{pformat}{object}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
146 Return the formatted representation of \var{object}. This takes into
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
147 account the options passed to the PrettyPrinter constructor.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
148 \end{funcdesc}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
149
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
150 \begin{funcdesc}{pprint}{object}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
151 Print the formatted representation of \var{object} on the configured
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
152 stream, followed by a newline.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
153 \end{funcdesc}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
154
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
155 The following methods provide the implementations for the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
156 corresponding functions of the same names. Using these methods on an
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
157 instance is slightly more efficient since new PrettyPrinter objects
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
158 don't need to be created.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
159
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
160 \begin{funcdesc}{isreadable}{object}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
161 Determine if the formatted representation of the object is
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
162 ``readable,'' or can be used to reconstruct the value using
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
163 \code{eval()}. Note that this returns false for recursive objects.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
164 If the \var{depth} parameter of the PrettyPrinter is set and the
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
165 object is deeper than allowed, this returns false.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
166 \end{funcdesc}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
167
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
168 \begin{funcdesc}{isrecursive}{object}
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
169 Determine if the object requires a recursive representation.
3a798677506c Documentation for the pprint module.
Fred Drake <fdrake@acm.org>
parents:
diff changeset
170 \end{funcdesc}