Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions peps/pep-0813.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Type: Standards Track
Created: 07-Nov-2025
Python-Version: 3.16
Post-History: `21-Feb-2026 <https://discuss.python.org/t/pep-813-the-pretty-print-protocol/106242>`__,
`04-Mar-2026 <https://discuss.python.org/t/pep-813-the-pretty-print-protocol/106242/79>`__
`04-Mar-2026 <https://discuss.python.org/t/pep-813-the-pretty-print-protocol/106242/79>`__,
`24-Oct-2026 <https://discuss.python.org/t/pep-813-the-pretty-print-protocol-round-2/109651>`__


Abstract
Expand Down Expand Up @@ -1217,8 +1218,9 @@ None at this time.
Change History
==============

* `[DD-Mmm-2026] <https://discuss.python.org/t/pep-813-the-pretty-print-protocol/106242/[NNN]>`__
* `24-Oct-2026 <https://discuss.python.org/t/pep-813-the-pretty-print-protocol-round-2/109651>`__

* Add a new default printer, ``pprint.Printer``, and leave ``pprint.PrettyPrinter`` unchanged.
* ``__pprint__()`` describes an object's structure, and the printer makes all layout decisions.
* Section markers ``pprint.VALUES``, ``pprint.KWARGS`` and ``pprint.ITEMS`` say how tuples are read,
replacing the reading of tuples by their shape and the "false-y" name for positional tuple values.
Expand All @@ -1228,13 +1230,12 @@ Change History
own vocabulary.
* Add ``pprint.decompose()``, and the ``pprint.LEAF`` sentinel that it returns for a leaf.
* Defer a table of markers in the default printer, and a way to change the default printer.
* Add ``pprint.DescriptionType`` for annotating ``__pprint__()`` methods.
* Add a ``hints`` attribute to ``pprint.Layout``, for particular printers.
* Add ``pprint.DescriptionType`` for type annotating ``__pprint__()`` methods.
* Add an optional ``hints`` attribute to ``pprint.Layout``, which can be used by third-party printers.
* Add a ``hug`` attribute to ``pprint.Layout``, so that ``defaultdict`` and similar types keep
``PrettyPrinter``'s layout.
* Add a new default printer, ``pprint.Printer``, and leave ``pprint.PrettyPrinter`` unchanged.
* A printer returns an iterable of lines, and ``!p`` joins them with ``'\n'``.
* Specify how the default printer lays out, sorts and limits the depth of nested objects, including keys
* Specify how the default printer lays out, sorts, and limits the depth of nested objects, including keys
that wrap.
* The default printer's ``expand`` option takes a ``pprint.Expand`` member: ``NEVER``, ``FIT`` or
``ALWAYS``. Its defaults are ``width=78``, ``indent=4`` and ``expand=Expand.FIT``.
Expand All @@ -1245,7 +1246,7 @@ Change History
* The default printer's ``number_format`` option replaces ``underscore_numbers``.
* Specify when an inherited ``__pprint__()`` is used, and explain why.
* :mod:`dataclasses` and :func:`~collections.namedtuple` generate ``__pprint__()`` methods.
* The ``!p`` format spec is a single replacement field, ``f'{obj!p:{printer}}'``, whose value is called
* The ``!p`` format spec can be a single replacement field, ``f'{obj!p:{printer}}'``, whose value is called
without first being converted to a string. Any other spec is a :exc:`SyntaxError`.
* A printer of ``None`` means the default printer, in f-strings, t-strings and ``PyObject_Pretty()``.
* In ``str.format()``, a format spec after ``!p`` pads the pretty printed string.
Expand Down
Loading