[Python-Dev] What if we didn't have repr?

Fernando Perez fperez.net at gmail.com
Fri May 24 05:04:42 CEST 2013


On Tue, 21 May 2013 06:36:54 -0700, Guido van Rossum wrote:

> Actually changing __str__ or __repr__ is out of the question, best we
> can do is discourage makingbthem different. But adding a protocol for
> pprint (with extra parameters to convey options) is a fair idea. I note
> that Nick sggested to use single-dispatch generic functions for this
> though. Both have pros and cons. Post design ideas to python-ideas
> please, not here!

Just in case you guys find this useful, in IPython we've sort of created 
this kind of 'extended repr protocol', described and illustrated here 
with examples:

http://nbviewer.ipython.org/url/github.com/ipython/ipython/raw/master/
examples/notebooks/Custom%20Display%20Logic.ipynb

It has proven to be widely used in practice.

Cheers,

f



More information about the Python-Dev mailing list