[Python-3000] Recursive str

Michael Urman murman at gmail.com
Wed Apr 16 07:16:36 CEST 2008


2008/4/15 Guido van Rossum <guido at python.org>:
> On Tue, Apr 15, 2008 at 6:10 PM, Michael Urman <murman at gmail.com> wrote:
>  >The third use, to represent strings unambiguously, is not a major point,
>
>  This is very much dependent on who is looking.
>
>  >  Similarly it's more useful to have '日本語' than to have '\u1234\u5678\u9abc'.
>
>  Again, that's not universally true.

It does depend on the use case. I base my comments on an expectation
that repr of str will be more commonly used to view contents than to
analyze strings character by character. Those doing the latter who
care about the difference between various 'a' look-alike characters
are doing so for very specific reasons, and can probably afford to "do
it right," whatever that ends up meaning.

>  The more I think about this, the more I believe that repr() should
>  *not* be changed, and that instead we should give people who like to
>  see '日本語' instead of '\u1234\u5678\u9abc' other tools to help
>  themselves.

I'll miss this, as I suspect the case of printing a list of unicode
strings will be fairly common. Given Unicode identifiers, even print
locals() could hit this. But perhaps tools for printing better
summaries of the contents of lists and dicts, or shell quoting (repr
as is makes a passable hack for quotes and spaces, but not unicode
characters), etc., can alleviate the pain well enough.

-- 
Michael Urman


More information about the Python-3000 mailing list