> Le jeudi 22 mai 2008 à 10:55 -0700, Guido van Rossum a écrit : >> Is this thread reaching a conclusion yet? I am hoping I can soon >> accept some variant of the following: >> >> 1. repr() returns a Unicode string containing only printable Unicode >> characters, using \x\u\U escapes for characters that are not >> considered printable according to some version of the Unicode standard >> augmented with some Python practicality, but unaffected by platform or >> locale. This can be implemented efficiently, without having to load >> the whole Unicode database, at least for strings containing only a >> large subset of the Unicode character set (e.g. all of UCS2, and >> possibly whole ranges of UCS4). >> >> 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 <[EMAIL PROTECTED]> 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. > 2to3 might even replace all occurrences of repr() by ascii(), to err on > the safe side. I'd be against that. 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. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com