[Python-Dev] What if we didn't have repr? (original) (raw)

Guido van Rossum guido at python.org
Tue May 21 15:36:54 CEST 2013


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!

--Guido

On Tuesday, May 21, 2013, Łukasz Langa wrote:

On 20 maj 2013, at 03:46, Guido van Rossum <guido at python.org<javascript:e({}, 'cvml', 'guido at python.org');>> wrote: > On Sun, May 19, 2013 at 4:27 PM, Gregory P. Smith <greg at krypto.org<javascript:e({}, 'cvml', 'greg at krypto.org');>> wrote: > Now you've got me wondering what Python would be like if repr, `` and repr never existed as language features. Upon first thoughts, I actually don't see much downside (no, i'm not advocating making that change). Something to ponder. >> I have pondered it many times, although usually in the form "Why do we need both str and repr?" >> What if we did the opposite? > 1. Make str() a protocol for arbitrary string conversion. 2. Move the current repr() contracts, both firm and informal to a new, extensible version of pprint. > There has been some discussion led by Raymond in 2010 about a general pprint rewrite and I'm willing to pick up the idea with a PEP for_ inclusion in 3.4. >>> __ http://bugs.python.org/issue7434_ > -- Best regards, Łukasz Langa > WWW: http://lukasz.langa.pl/ Twitter: @llanga IRC: ambv on #python-dev >

--Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130521/187ebc80/attachment.html>



More information about the Python-Dev mailing list