[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>:

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
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>

More information about the New-bugs-announce mailing list