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.

classification
Title: Negative values in positional access inside formatting
Type: enhancement Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Should str.format allow negative indexes when used for __getitem__ access?
View: 7951
Assigned To: Nosy List: eric.smith, facundobatista
Priority: normal Keywords:

Created on 2018-03-27 21:07 by facundobatista, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (1)
msg314549 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2018-03-27 21:07
This works fine:

>>> "{[0]}".format([1, 2, 3])
'1'

This should work too:

>>> "{[-1]}".format([1, 2, 3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: list indices must be integers or slices, not str
History
Date User Action Args
2022-04-11 14:58:59adminsetgithub: 77341
2018-03-27 21:43:24serhiy.storchakasetstatus: open -> closed
superseder: Should str.format allow negative indexes when used for __getitem__ access?
resolution: duplicate
stage: resolved
2018-03-27 21:13:54ned.deilysetnosy: + eric.smith

type: enhancement
versions: + Python 3.8, - Python 3.6
2018-03-27 21:07:48facundobatistacreate