Skip to content

Commit 9c088d3

Browse files
committed
Mention restriction of the existing pprint module. Add a section on !p for f-strings and str.format().
1 parent bba5028 commit 9c088d3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

peps/pep-0813.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ Rationale
3333
=========
3434

3535
Pretty printing is very useful for displaying complex data structures, like dictionaries read from JSON
36-
content. By providing a way for classes to customize how their instances participate in pretty printing,
36+
content. However, the existing :mod:`pprint` module can only format builtin objects that it knows about.
37+
By providing a way for classes to customize how their instances participate in pretty printing,
3738
users have more options for visually improving the display of their complex data, especially for debugging.
3839

3940
By extending the built-in :func:`print` function to automatically pretty print its output, debugging with
@@ -97,6 +98,14 @@ Built-in :func:`print` takes a new optional argument, appended to the end of the
9798
performs implicit instantiation.
9899

99100

101+
Additions to ``f-strings`` and ``str.format()``
102+
-----------------------------------------------
103+
104+
In addition to the existing ``!s``, ``!r``, and ``!a`` conversion specifiers, an additional ``!p``
105+
conversion will be added. The effect of this specifier with an expression ``value`` will be to call
106+
:py:meth:`pprint.pformat(value)`. In this initial specification, it will be an error to provide any format
107+
specifier if ``!p`` is used.
108+
100109
Examples
101110
========
102111

0 commit comments

Comments
 (0)