This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients eric.araujo, eric.smith, gosella, mark.dickinson
Date 2010-06-12.21:23:17
SpamBayes Score 2.5563804e-05
Marked as misclassified No
Message-id <1276377800.1.0.480537705523.issue8985@psf.upfronthosting.co.za>
In-reply-to
Content
get_integer uses the narrowest possible definition for integer indexes, in order to pass all other strings to mappings.

>>> '{0[ 0 ]} {0[-1]}'.format({' 0 ': 'foo', '-1': 'bar'})
'foo bar'

Remember, it has to guess what type of lookup to do based on whether the value inside [] looks like an integer or not.

From the PEP:
    Because keys are not quote-delimited, it is not possible to
    specify arbitrary dictionary keys (e.g., the strings "10" or
    ":-]") from within a format string.

I don't believe this restriction causes any practical problem.

I'm not sure the error could be improved. The code that's being called is essentially:

>>> [0, 1, 2]['-1']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: list indices must be integers, not str
History
Date User Action Args
2010-06-12 21:23:20eric.smithsetrecipients: + eric.smith, mark.dickinson, eric.araujo, gosella
2010-06-12 21:23:20eric.smithsetmessageid: <1276377800.1.0.480537705523.issue8985@psf.upfronthosting.co.za>
2010-06-12 21:23:18eric.smithlinkissue8985 messages
2010-06-12 21:23:17eric.smithcreate