Skip to content

Commit 143cb6c

Browse files
committed
The dunder is __pprint__(), not __pretty__()
1 parent b8fc7e4 commit 143cb6c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

peps/pep-0813.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ Specification
4848
There are two parts to this proposal.
4949

5050

51-
``__pretty__()`` methods
51+
``__pprint__()`` methods
5252
------------------------
5353

54-
Classes can implement a new dunder method, ``__pretty__()`` which if present, generates the pretty printed
54+
Classes can implement a new dunder method, ``__pprint__()`` which if present, generates the pretty printed
5555
representation of their instances. This augments ``__repr__()`` which, prior to this proposal, was the only
5656
method used to generate a pretty representation of the object. Since object reprs provide functionality
5757
distinct from pretty printing, some classes may want more control over their pretty display.
5858

59-
``__pretty__()`` is optional; if missing, the standard pretty printers fall back to ``__repr__()``
59+
``__pprint__()`` is optional; if missing, the standard pretty printers fall back to ``__repr__()``
6060
for full backward compatibility (technically speaking, :py:func:`python:pprint.saferepr` is used).
61-
However, if defined on a class, ``__pretty__()`` has the same argument signature as
61+
However, if defined on a class, ``__pprint__()`` has the same argument signature as
6262
:py:meth:`python:pprint.PrettyPrinter.format`, taking four arguments:
6363

6464
* ``object`` - the object to print, which is effectively always ``self``
@@ -67,7 +67,7 @@ However, if defined on a class, ``__pretty__()`` has the same argument signature
6767
* ``maxlevels`` - the requested limit to recursion
6868
* ``levels`` - the current recursion level
6969

70-
Similarly, ``__pretty__()`` returns three values, the string to be used as the pretty printed representation,
70+
Similarly, ``__pprint__()`` returns three values, the string to be used as the pretty printed representation,
7171
a boolean indicating whether the returned value is "readable", and a boolean indicating whether recursion has
7272
been detected. In this context, "readable" means the same as
7373
:py:meth:`python:pprint.PrettyPrinter.isreadable`, i.e. that the returned value can be used to reconstruct the

0 commit comments

Comments
 (0)