On Wed, 27 Jul 2011 16:31:54 +0300
Eli Bendersky <[email protected]> wrote:
>
> I wasn't aware of '%a' at all? It doesn't appear to be documented, and
> Python 2.6 doesn't support it:
>
> ValueError: unsupported format character 'a' (0x61) at index 1
>
> If it's new, it should at least be documented in library/stdtypes with the
> other formatting operations.
It's new in 3.x and maps to the ascii() builtin:
>>> ascii('hé')
"'h\\xe9'"
>>> '%a' % 'hé'
"'h\\xe9'"
The docstring for ascii():
ascii(object) -> string
As repr(), return a string containing a printable representation of
an object, but escape the non-ASCII characters in the string
returned by repr() using \x, \u or \U escapes. This generates a
string similar to that returned by repr() in Python 2.
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com