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

Atsuo Ishimoto ishimoto at gembook.org
Fri May 23 03:46:31 CEST 2008


On Fri, May 23, 2008 at 6:18 AM, Guido van Rossum <guido at python.org> wrote:

>>> 2. If you don't want any non-ASCII printed to a file, set the file's
>>> encoding to ASCII and the error handler to backslashescape.
>
> On Thu, May 22, 2008 at 12:59 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
>> Since some people still seem wary that repr() might return non-ascii
>> results, perhaps we could also:
>>
>> 3. Add a builtin function named ascii() and a formatting code "%a" that
>> both call repr() internally and then convert all non-ascii characters to
>> \uXXXX escapes.
>
> I'd call that a stretch goal, but it seems an easy one.

Martin may against for new builtin function. Perhaps
string.asciirepr() might better?

>
> Could someone (Atsuo?) write up a new version for the PEP, adding the
> conclusions reached in this thread and recapping some of the
> discussion? I think this can get in before the first beta release, and
> that seems doable.
>

I'll revise the PEP and the patch soon.
One point still remains is default error handler for sys.stdout. I can
live with 'strict' error handler, but I think raising exceptions for
evenry un-supported characters by default is too exacting.


More information about the Python-3000 mailing list