[issue12014] str.format parses replacement field incorrectly
Ben Wolfson
report at bugs.python.org
Fri May 6 16:41:36 CEST 2011
Ben Wolfson <wolfson at gmail.com> added the comment:
The semantics the docs suggest for index fields (namely that whatever is in the index field is just passed to getitem) do seem to be right, no other processing is done here, for instance:
>>> d = {"{0}":"hi"}
>>> "{0[{0}]}".format(d)
'hi'
>>> import string
>>> list(string.Formatter().parse("{0[{0}]}"))
[('', '0[{0}]', '', None)]
>>>
Which is what you'd expect, but makes me think that treating "!" and ":" in the index field separately is definitely wrong.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12014>
_______________________________________
More information about the Python-bugs-list
mailing list