Author eric.smith
Recipients eric.smith
Date 2010-02-17.23:54:16
SpamBayes Score 4.66558e-10
Marked as misclassified No
Message-id <1266450859.13.0.906832569526.issue7951@psf.upfronthosting.co.za>
In-reply-to
Content
It surprised me that this doesn't work:
>>> "{0[-1]}".format('fox')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: string indices must be integers

I was expecting it to be equivalent to:

>>> "{0[2]}".format('fox')
'x'

I don't think there's any particular reason this doesn't work. It would, however break the following code:

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

But note that this doesn't work currently:

>>> "{0[1]}".format({'1':'foo'})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 1
History
Date User Action Args
2010-02-17 23:54:19eric.smithsetrecipients: + eric.smith
2010-02-17 23:54:19eric.smithsetmessageid: <1266450859.13.0.906832569526.issue7951@psf.upfronthosting.co.za>
2010-02-17 23:54:17eric.smithlinkissue7951 messages
2010-02-17 23:54:16eric.smithcreate