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!<div>
<br></div><div>--Guido<span></span><br><br>On Tuesday, May 21, 2013, Łukasz Langa  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">
<div><div>On 20 maj 2013, at 03:46, Guido van Rossum <<a href="javascript:_e({}, 'cvml', 'guido@python.org');" target="_blank">guido@python.org</a>> wrote:</div><br><blockquote type="cite">On Sun, May 19, 2013 at 4:27 PM, Gregory P. Smith <<a href="javascript:_e({}, 'cvml', 'greg@krypto.org');" target="_blank">greg@krypto.org</a>> wrote:<br>
<blockquote type="cite">Now you've got me wondering what Python would be like if repr, `` and<br>__repr__ never existed as language features. Upon first thoughts, I actually<br>don't see much downside (no, i'm not advocating making that change).<br>
Something to ponder.<br></blockquote><br>I have pondered it many times, although usually in the form "Why do we<br>need both str and repr?"<br></blockquote></div><div><br></div><div>What if we did the opposite?</div>
<div><br></div><div>1. Make __str__() a protocol for arbitrary string conversion.</div><div>2. Move the current __repr__() contracts, both firm and informal to a new, extensible version of pprint.</div><div><br></div><div>
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.</div><div><br></div><div><br></div><div><br></div>__ <a href="http://bugs.python.org/issue7434" target="_blank">http://bugs.python.org/issue7434</a><div>
<br><div>
<div style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:'Lucida Grande';word-wrap:break-word;word-spacing:0px">
-- <br>Best regards,<br>Łukasz Langa<br><br>WWW: <a href="http://lukasz.langa.pl/" target="_blank">http://lukasz.langa.pl/</a><br>Twitter: @llanga<br>IRC: ambv on #python-dev</div>
</div>
<br></div></div></blockquote></div><br><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>