[New-bugs-announce] [issue7928] String formatting: grammar wrongly limits [index] to integer

Edward Welbourne report at bugs.python.org
Sun Feb 14 12:29:06 CET 2010


New submission from Edward Welbourne <eddy at chaos.org.uk>:

http://docs.python.org/library/string.html#formatstrings
field_name        ::=  (identifier | integer) ("." attribute_name | "[" element_index "]")*
element_index     ::= integer

Subsequent text indicates __getitem__() is used but does not overtly say that a string can be used; but
http://docs.python.org/whatsnew/2.6.html#pep-3101-advanced-string-formatting
gives the example
>>> 'Content-type: {0[.mp4]}'.format(mimetypes.types_map)
and clearly '.mp4' is passed to __getitem__(); a string, not an integer.

Clearly one of these is wrong !
Given that the "what's new" doc goes into some detail about how the content of [...] gets parsed, I'm guessing it's right and the grammar is wrong.

----------
assignee: georg.brandl
components: Documentation
messages: 99340
nosy: eddy, georg.brandl
severity: normal
status: open
title: String formatting: grammar wrongly limits [index] to integer
versions: Python 2.6

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


More information about the New-bugs-announce mailing list