mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#13579: teach string.Formatter about 'a'.
Patch by Francisco Martín Brugué.
This commit is contained in:
parent
828607170d
commit
e56bf97ef4
4 changed files with 26 additions and 9 deletions
|
@ -236,12 +236,14 @@ class Formatter:
|
|||
|
||||
def convert_field(self, value, conversion):
|
||||
# do any conversion on the resulting object
|
||||
if conversion == 'r':
|
||||
return repr(value)
|
||||
if conversion is None:
|
||||
return value
|
||||
elif conversion == 's':
|
||||
return str(value)
|
||||
elif conversion is None:
|
||||
return value
|
||||
elif conversion == 'r':
|
||||
return repr(value)
|
||||
elif conversion == 'a':
|
||||
return ascii(value)
|
||||
raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue