[New-bugs-announce] [issue32117] Tuple unpacking in return and yield statements
David Cuthbert
report at bugs.python.org
Wed Nov 22 18:31:49 EST 2017
New submission from David Cuthbert <dacut at kanga.org>:
This stems from a query on StackOverflow: https://stackoverflow.com/questions/47272460/python-tuple-unpacking-in-return-statement/
Specifically, the following syntax is allowed:
def f():
rest = (4, 5, 6)
t = 1, 2, 3, *rest
While the following result in SyntaxError:
def g():
rest = (4, 5, 6)
return 1, 2, 3, *rest
def h():
rest = (4, 5, 6)
yield 1, 2, 3, *rest
Looking at the original commit that enabled tuple unpacking in assignment statements:
https://github.com/python/cpython/commit/4905e80c3d2f6abb613d212f0313d1dfe09475dc
I don't believe this difference is intentional.
My GitHub repo incorporates a fix for this; I'll file a pull request momentarily.
----------
components: Interpreter Core
messages: 306761
nosy: dacut
priority: normal
severity: normal
status: open
title: Tuple unpacking in return and yield statements
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32117>
_______________________________________
More information about the New-bugs-announce
mailing list