Skip to content

Commit 1dc7857

Browse files
committed
Describe the new PyObject_Pretty() function
1 parent dbbe148 commit 1dc7857

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

peps/pep-0813.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ will be added. The effect of this specifier with an expression ``value`` will b
108108
:py:func:`python:pprint.pformat`, passing ``value`` as the only argument. In this initial specification, it
109109
will be an error to provide any format specifier if ``!p`` is used.
110110

111+
Additions to the C-API
112+
----------------------
113+
114+
To support ``!p``, a new function, ``PyObject_Pretty()`` is added to the
115+
`Limited C API <https://docs.python.org/3/c-api/stable.html#limited-c-api>`_.
116+
This function takes a single ``PyObject *``, the object to pretty print. This
117+
function imports the ``pprint`` module and calls :func:`pprint.pformat` with
118+
this object as its argument, returning the results.
119+
111120
.. _examples:
112121

113122
Examples
@@ -305,6 +314,7 @@ Change History
305314
* Specify that the ``!p`` conversion in f-strings and ``str.format()`` implicitly perform an
306315
import of the ``pprint`` module.
307316
* Clarify the language around the new optional keyword-only argument ``pretty`` to ``print()``.
317+
* Describe the new Limited C API function ``PyObject_Pretty()``.
308318

309319

310320
Copyright

0 commit comments

Comments
 (0)