From 943e77d42d3f84b581f32c05f1fc8c05366b8ed3 Mon Sep 17 00:00:00 2001 From: Irit Katriel <1055913+iritkatriel@users.noreply.github.com> Date: Fri, 2 Jul 2021 10:42:08 +0100 Subject: =?UTF-8?q?bpo-34798:=20[doc]=20clearer=20presentation=20of=20ppri?= =?UTF-8?q?nt.PrettyPrinter=20constru=E2=80=A6=20(GH-26967)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Doc/library/pprint.rst | 48 ++++++++++++++-------- .../2021-06-30-13-29-49.bpo-34798.t7FCa0.rst | 1 + 2 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2021-06-30-13-29-49.bpo-34798.t7FCa0.rst 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 -- cgit v0.12