Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70175
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: indexing in format strings |
| Date | 2014-04-11 22:44 -0400 |
| References | <HrednSzZyaoTwtXOnZ2dnUVZ8kydnZ2d@brightview.co.uk> <ieGdnV5uV5-06tXOnZ2dnUVZ7vWdnZ2d@brightview.co.uk> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.9221.1397270674.18130.python-list@python.org> (permalink) |
On 4/11/2014 7:13 PM, blindanagram wrote:
> On 11/04/2014 22:33, blindanagram wrote:
>
> Thanks, Mark and Terry, for your rapid responses.
>
> An interesting thread.
It just occurred to me today, and I verified, that '+1' is also seen as
a string.
>>> '{0[-1]}'.format({'-1': 'neg int key'})
'neg int key'
>>> '{0[+1]}'.format({'+1': 'neg int key'})
'neg int key'
>>> '{0[+1]}'.format([1,2,3])
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
'{0[+1]}'.format([1,2,3])
TypeError: list indices must be integers, not str
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
indexing in format strings blindanagram <noone@nowhere.net> - 2014-04-11 22:33 +0100
Re: indexing in format strings Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-04-11 22:43 +0100
Re: indexing in format strings Terry Reedy <tjreedy@udel.edu> - 2014-04-11 17:45 -0400
Re: indexing in format strings blindanagram <noone@nowhere.net> - 2014-04-12 00:13 +0100
Re: indexing in format strings Terry Reedy <tjreedy@udel.edu> - 2014-04-11 22:44 -0400
csiph-web