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. Regards Antoine.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4