[Python-Dev] [Python-checkins] cpython: Issue #11049: adding some tests to test.support

Eli Bendersky eliben at gmail.com
Wed Jul 27 15:54:34 CEST 2011


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

> On Wed, 27 Jul 2011 16:31:54 +0300
> Eli Bendersky <eliben at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110727/5e694aed/attachment.html>


More information about the Python-Dev mailing list