[Python-3000] PEP 3138- String representation in Python 3000

Jim Jewett jimjjewett at gmail.com
Tue May 27 21:33:02 CEST 2008


On 5/27/08, M.-A. Lemburg <mal at egenix.com> wrote:
> On 2008-05-27 05:02, Stephen J. Turnbull wrote:
> > ... repr() Spanish and Chinese users are going to feel more or less
> > differently from Americans about which characters should be escaped.

>  I'm not sure that's always the case, but users should certainly
>  have the freedom to decide whether they prefer backslashed quoted
>  code points or glyphs on their screen.

Agreed, and they already do if they go far enough out of their way to
be explicit.

The question is what to do by default.

We agree that, by default, str(x) should display glyphs when possible.
 (And changing this is hard in practice, even if you don't recognize
the glyphs.)

We agree that, by default today, repr uses backslash.  (And changing
this is hard, even if you do recognize the glyphs.)

We agree also agree that in many cases, people want the glyphs but get
a backslash.

The only disagreement is over how to fix this.

PEP 3138 says that repr should start printing unicode glyphs.

I say that repr should (insetad) start recognizing when it was called
in place of __str__, and should revert back to __str__ when it
recurses down to the next level.

-jJ


More information about the Python-3000 mailing list