[Python-3000] PEP 3138- String representation in Python 3000
Jim Jewett
jimjjewett at gmail.com
Tue May 27 00:53:41 CEST 2008
On 5/24/08, Oleg Broytmann <phd at phd.pp.ru> wrote:
> On Sat, May 24, 2008 at 12:53:08PM -0400, Jim Jewett wrote:
> > if I want pretty, I'll use print (or pprint).
> str(container_of_strings) uses repr(), so you loose prettiness on either
> print or '%s' % container_of_strings.
This is not a problem with repr; it is a bug with str.
I certainly support a flag for repr meaning "This was really str; repr
got called because the container doesn't have str, but go back to str
for the contents." (Alternatively, write an explicit repr that does
that, add it to the builtin types, and make it available for easy use
with extensions.)
> Exceptions use repr() for file names,
> e.g., which is very inconvenient, IMHO.
I'm not sure I fully understand this problem, but I would expect the
right solution to be a change to either Exception.__str__ or the way
filename-related exceptions are initialized. Changing all of repr is
again overkill.
-jJ
More information about the Python-3000
mailing list