-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tuple unpacking in return and yield statements #76298
Comments
This stems from a query on StackOverflow: https://stackoverflow.com/questions/47272460/python-tuple-unpacking-in-return-statement/ Specifically, the following syntax is allowed: While the following result in SyntaxError: def h():
rest = (4, 5, 6)
yield 1, 2, 3, *rest Looking at the original commit that enabled tuple unpacking in assignment statements: I don't believe this difference is intentional. My GitHub repo incorporates a fix for this; I'll file a pull request momentarily. |
Since this changes the grammar, it should be first discussed on Python-Dev and approved by BDFL. |
CLA processed, and BDFL has assented on python-dev. Serhiy, thoughts on next steps? |
I think the language spec needs updating as well? In particular in https://docs.python.org/3/reference/simple_stmts.html#the-return-statement it seems expression_list should be replaced by starred_list. |
Hm... that leaves the only production for expression_list as: And I'm not sure that this shouldn't also be replaced by starred_list. It's not accepted today, though: In [6]: a[1,(4, 5, 6)] I will ask about this again on python-dev@ |
Oops, I wasn't looking broadly enough. This is also used in the augmented assignment statements syntax, e.g. a += 1, 2, 3 |
Move to 3.8. |
Jordan, what's your GitHub account name? I hope you can check this out and make the changes I'm requesting on GitHub. |
Here's my GitHub account: I'll make the changes and rebase as soon as I get home. |
Sorry, I could have sworn that I pasted my link... https://github.com/jChapman |
Fixed by #4509. |
assertEquals() is deprecated, use assertEqual() instead. This causes tests failure when run with -Werror. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: