[New-bugs-announce] [issue32626] Subscript unpacking raises SyntaxError
Ben Burrill
report at bugs.python.org
Mon Jan 22 17:39:59 EST 2018
New submission from Ben Burrill <bburrill98 at gmail.com>:
PEP 448 defines unpacking generalizations for tuples. However, this does not currently work for subscripted tuples that are not delimited by parentheses.
Current behavior (Tested on 3.6/3.7a4):
>>> class Subscriptable:
... def __getitem__(self, item):
... return item
...
>>> ss = Subscriptable()
>>>
>>> 1, 2, 3
(1, 2, 3)
>>> ss[1, 2, 3]
(1, 2, 3)
>>> *range(5), 42
(0, 1, 2, 3, 4, 42)
>>> ss[*range(5), 42] # This should be the same as above
File "<stdin>", line 1
ss[*range(5), 42]
^
SyntaxError: invalid syntax
>>> ss[(*range(5), 42)] # Workaround
(0, 1, 2, 3, 4, 42)
----------
components: Interpreter Core
messages: 310447
nosy: Ben Burrill
priority: normal
severity: normal
status: open
title: Subscript unpacking raises SyntaxError
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32626>
_______________________________________
More information about the New-bugs-announce
mailing list