diff options
-rw-r--r-- | Doc/library/pprint.rst | 48 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-06-30-13-29-49.bpo-34798.t7FCa0.rst | 1 |
2 files changed, 31 insertions, 18 deletions
diff --git a/Doc/library/pprint.rst b/Doc/library/pprint.rst index f45c66f..8f37450 100644 --- a/Doc/library/pprint.rst +++ b/Doc/library/pprint.rst @@ -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). diff --git a/Misc/NEWS.d/next/Library/2021-06-30-13-29-49.bpo-34798.t7FCa0.rst b/Misc/NEWS.d/next/Library/2021-06-30-13-29-49.bpo-34798.t7FCa0.rst new file mode 100644 index 0000000..ab9fd8e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2021-06-30-13-29-49.bpo-34798.t7FCa0.rst @@ -0,0 +1 @@ +Break up paragraph about :class:`pprint.PrettyPrinter` construction parameters to make it easier to read.
\ No newline at end of file |