[issue13579] string.Formatter doesn't understand the !a conversion specifier

Nick Coghlan report at bugs.python.org
Sun Dec 11 08:10:50 CET 2011


New submission from Nick Coghlan <ncoghlan at gmail.com>:

As the subject line says:

>>> fmt = "{0!a}"
>>> fmt.format(10)
'10'
>>> import string
>>> string.Formatter().format(fmt, 10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/string.py", line 180, in format
    return self.vformat(format_string, args, kwargs)
  File "/usr/lib/python3.2/string.py", line 184, in vformat
    result = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/usr/lib/python3.2/string.py", line 210, in _vformat
    obj = self.convert_field(obj, conversion)
  File "/usr/lib/python3.2/string.py", line 245, in convert_field
    raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
ValueError: Unknown conversion specifier a

----------
messages: 149214
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: string.Formatter doesn't understand the !a conversion specifier

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13579>
_______________________________________


More information about the Python-bugs-list mailing list