Éric Araujo added the comment:
Just for the record, I said something inexact in my previous message in this
thread. New features go to the dev branch (py3k, future 3.2), bug and doc
fixes go into py3k and the stable branches (2.7 and 3.1 now), and the previous
stable releases (2.5 and 2.6) o
Eric Smith added the comment:
I'll consider this a duplicate. Issue 7951 is the existing feature request for
this issue. I'll merge the nosy lists.
--
resolution: rejected -> duplicate
superseder: -> Should str.format allow negative indexes when used for
__getitem__ access?
Germán L. Osella Massa added the comment:
I now see the rationale behind not accepting ' 10 ' == 10. But what about not
accepting '-1' == -1?
I think is odd that negative numbers are not accepted as valid indexes. I'd
expect that something like
"First element is {0[0]} and last element is {
Eric Smith added the comment:
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 v
Éric Araujo added the comment:
FYI, the version field is used to note versions where the bug will be fixed,
not versions where it’s found. New features and bug fixes go to the dev branch
(3.2), security and documentation fixes go to the stable branches (2.6 and
3.1). (2.7 is in release candid
Mark Dickinson added the comment:
The behaviour is by design (I think), though perhaps the error messages could
be improved.
Are you asking for negative indices and extra space to be accepted? In that
case this should be a feature request rather than a bug report.
--
nosy: +eric.smi
New submission from Germán L. Osella Massa :
The str.format() method allows index lookup on an object that supports
__getitem__(). However, negative indexes are not supported.
Examples (using Python 2.6.5):
>>> "{0[0]}".format([0, 1, 2])
'0'
>>> "{0[-1]}".format([0, 1, 2])
Traceback (most rec