""Martin v. Löwis"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
What are others' opinions?  Any insight to this design decision?

The intention is that all printable characters in a string get displayed
in repr. This was in particular requested by Japanese users (but also by
other users of non-ASCII characters) which complained that repr() is
fairly useless if your strings actually contains *no* ASCII characters
(but all of them are printable).

Notice that repr() of the string actually succeeds; try

x='\u5000'
z=repr(x)

It is the printing of the repr that fails.

Maybe repr() should always display the ASCII representation with
escapes for all other characters

You can use the ascii() builtin if you want that.

especially considering the "repr() should produce output suitable for
eval() when possible" rule.

But that is preserved under the new behavior, also! Just try

py> x='\u5000'
py> eval(repr(x))==x
True

Regards,
Martin

Thanks Martin, it's clear now. I just read about the new ascii() function before seeing your reply.

P.S. How did you manage to get U+5000 into your data, on a system where
the terminal encoding is cp437? Google translates it as "Rash"; the
Unihan database also has "bewildered", "wildly".

I just picked that example out of the air. I study Chinese and knew it was a character in that area of the Unicode map. My usual editors (PythonWin and PyAlaMode from wxPython) don't work with Python 3, which was why I was using the Windows cmd prompt.

Thanks,
Mark
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to