Message107705
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 |
|
Date |
User |
Action |
Args |
2010-06-12 21:23:20 | eric.smith | set | recipients:
+ eric.smith, mark.dickinson, eric.araujo, gosella |
2010-06-12 21:23:20 | eric.smith | set | messageid: <1276377800.1.0.480537705523.issue8985@psf.upfronthosting.co.za> |
2010-06-12 21:23:18 | eric.smith | link | issue8985 messages |
2010-06-12 21:23:17 | eric.smith | create | |
|