mirror of https://github.com/python/cpython.git
bpo-34798: [doc] clearer presentation of pprint.PrettyPrinter constru… (GH-26967)
This commit is contained in:
parent
85b920498b
commit
943e77d42d
|
@ -42,24 +42,36 @@ The :mod:`pprint` module defines one class:
|
|||
compact=False, sort_dicts=True, underscore_numbers=False)
|
||||
|
||||
Construct a :class:`PrettyPrinter` instance. This constructor understands
|
||||
several keyword parameters. An output stream may be set using the *stream*
|
||||
keyword; the only method used on the stream object is the file protocol's
|
||||
:meth:`write` method. If not specified, the :class:`PrettyPrinter` adopts
|
||||
``sys.stdout``. The
|
||||
amount of indentation added for each recursive level is specified by *indent*;
|
||||
the default is one. Other values can cause output to look a little odd, but can
|
||||
make nesting easier to spot. The number of levels which may be printed is
|
||||
controlled by *depth*; if the data structure being printed is too deep, the next
|
||||
contained level is replaced by ``...``. By default, there is no constraint on
|
||||
the depth of the objects being formatted. The desired output width is
|
||||
constrained using the *width* parameter; the default is 80 characters. If a
|
||||
structure cannot be formatted within the constrained width, a best effort will
|
||||
be made. If *compact* is false (the default) each item of a long sequence
|
||||
will be formatted on a separate line. If *compact* is true, as many items
|
||||
as will fit within the *width* will be formatted on each output line. If
|
||||
*sort_dicts* is true (the default), dictionaries will be formatted with their
|
||||
keys sorted, otherwise they will display in insertion order. If
|
||||
*underscore_numbers* is true, integers will be formatted with the
|
||||
several keyword parameters.
|
||||
|
||||
*stream* (default ``sys.stdout``) is a :term:`file-like object` to
|
||||
which the output will be written by calling its :meth:`write` method.
|
||||
|
||||
Other values configure the manner in which nesting of complex data
|
||||
structures is displayed.
|
||||
|
||||
*indent* (default 1) specifies the amount of indentation added for
|
||||
each nesting level.
|
||||
|
||||
*depth* controls the number of nesting levels which may be printed; if
|
||||
the data structure being printed is too deep, the next contained level
|
||||
is replaced by ``...``. By default, there is no constraint on the
|
||||
depth of the objects being formatted.
|
||||
|
||||
*width* (default 80) specifies the desired maximum number of characters per
|
||||
line in the output. If a structure cannot be formatted within the width
|
||||
constraint, a best effort will be made.
|
||||
|
||||
*compact* impacts the way that long sequences (lists, tuples, sets, etc)
|
||||
are formatted. If *compact* is false (the default) then each item of a
|
||||
sequence will be formatted on a separate line. If *compact* is true, as
|
||||
many items as will fit within the *width* will be formatted on each output
|
||||
line.
|
||||
|
||||
If *sort_dicts* is true (the default), dictionaries will be formatted with
|
||||
their keys sorted, otherwise they will display in insertion order.
|
||||
|
||||
If *underscore_numbers* is true, integers will be formatted with the
|
||||
``_`` character for a thousands separator, otherwise underscores are not
|
||||
displayed (the default).
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Break up paragraph about :class:`pprint.PrettyPrinter` construction parameters to make it easier to read.
|
Loading…
Reference in New Issue