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 2018-03-27 21:43 by serhiy.storchaka. 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
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