On Wed, Jul 27, 2011 at 16:44, Antoine Pitrou <solip...@pitrou.net> wrote:

> On Wed, 27 Jul 2011 16:31:54 +0300
> Eli Bendersky <eli...@gmail.com> 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.
>
>
Thanks. I also saw this documented in the {!a} formatting documentation.

Was it left out of the library/stdtypes doc on purpose (to encourage the new
str.format), or is this an omission?

Eli
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to