PEP 813 - The Pretty Print Protocol

@ericvsmith and I thank you all for your insightful feedback. We’ve now published an update, which adopt many of the suggestions, and defers or explicitly rejects others.

The big TL;DR is that we’re dropping the changes to built-in print(). @bitdancer and others were pretty convincing that the granularity of the proposed pretty argument was wrong[1] and that !p for f-strings will do what we need. After working with @pablogsal to flesh out the implementation and convince ourselves that adding !p:expression format specs (only for f-strings!) would work, we felt happy with this change.

We’ve updated the examples[2], tightened up the __pprint__() protocol description, and explicitly proposed adding PyObject_Pretty() to the Limited C API.

Enjoy!


  1. something that we knew in our gut ↩︎

  2. with hilarity, since Pygments didn’t like us using !p in the f-string examples! ↩︎

3 Likes