Skip to content

Commit 451067b

Browse files
pythongh-115986: Use param list to mark up pprint.PrettyPrinter constructor
1 parent 3409bc2 commit 451067b

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

Doc/library/pprint.rst

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -117,51 +117,50 @@ Functions
117117
PrettyPrinter Objects
118118
---------------------
119119

120-
This module defines one class:
121-
122-
.. First the implementation class:
123-
124-
125120
.. index:: single: ...; placeholder
126121

127122
.. class:: PrettyPrinter(indent=1, width=80, depth=None, stream=None, *, \
128123
compact=False, sort_dicts=True, underscore_numbers=False)
129124

130-
Construct a :class:`PrettyPrinter` instance. This constructor understands
131-
several keyword parameters.
132-
133-
*stream* (default :data:`!sys.stdout`) is a :term:`file-like object` to
134-
which the output will be written by calling its :meth:`!write` method.
135-
If both *stream* and :data:`!sys.stdout` are ``None``, then
136-
:meth:`~PrettyPrinter.pprint` silently returns.
137-
138-
Other values configure the manner in which nesting of complex data
139-
structures is displayed.
140-
141-
*indent* (default 1) specifies the amount of indentation added for
142-
each nesting level.
143-
144-
*depth* controls the number of nesting levels which may be printed; if
145-
the data structure being printed is too deep, the next contained level
146-
is replaced by ``...``. By default, there is no constraint on the
147-
depth of the objects being formatted.
148-
149-
*width* (default 80) specifies the desired maximum number of characters per
150-
line in the output. If a structure cannot be formatted within the width
151-
constraint, a best effort will be made.
152-
153-
*compact* impacts the way that long sequences (lists, tuples, sets, etc)
154-
are formatted. If *compact* is false (the default) then each item of a
155-
sequence will be formatted on a separate line. If *compact* is true, as
156-
many items as will fit within the *width* will be formatted on each output
157-
line.
158-
159-
If *sort_dicts* is true (the default), dictionaries will be formatted with
160-
their keys sorted, otherwise they will display in insertion order.
161-
162-
If *underscore_numbers* is true, integers will be formatted with the
163-
``_`` character for a thousands separator, otherwise underscores are not
164-
displayed (the default).
125+
Construct a :class:`PrettyPrinter` instance.
126+
127+
:param int indent:
128+
The amount of indentation added for each nesting level.
129+
130+
:param int width:
131+
The desired maximum number of characters per line in the output.
132+
If a structure cannot be formatted within the width constraint,
133+
a best effort will be made.
134+
135+
:param depth:
136+
The number of nesting levels which may be printed.
137+
If the data structure being printed is too deep,
138+
the next contained level is replaced by ``...``.
139+
If ``None`` (the default), there is no constraint
140+
on the depth of the objects being formatted.
141+
:type depth: int | None
142+
143+
:param stream:
144+
A file-like object to which the output will be written
145+
by calling its :meth:`!write` method.
146+
If ``None`` (the default), :data:`sys.stdout` is used.
147+
:type stream: :term:`file-like object` | None
148+
149+
:param bool compact:
150+
Control the way long :term:`sequences <sequence>` are formatted.
151+
If ``False`` (the default),
152+
each item of a sequence will be formatted on a separate line,
153+
otherwise as many items as will fit within the *width*
154+
will be formatted on each output line.
155+
156+
:param bool sort_dicts:
157+
If ``True`` (the default), dictionaries will be formatted with
158+
their keys sorted, otherwise they will display in insertion order.
159+
160+
:param bool underscore_numbers:
161+
If ``True``,
162+
integers will be formatted with the ``_`` character for a thousands separator,
163+
otherwise underscores are not displayed (the default).
165164

166165
.. versionchanged:: 3.4
167166
Added the *compact* parameter.
@@ -213,6 +212,8 @@ This module defines one class:
213212
Print the formatted representation of *object* on the configured stream,
214213
followed by a newline.
215214

215+
If :data:`sys.stdout` is ``None``, :meth:`!pprint` silently returns.
216+
216217
The following methods provide the implementations for the corresponding
217218
functions of the same names. Using these methods on an instance is slightly
218219
more efficient since new :class:`PrettyPrinter` objects don't need to be

0 commit comments

Comments
 (0)