mirror of https://github.com/python/cpython
7d3497f617
To recap: the objective is to make starred expressions valid in `subscription`, which is used for generics: `Generic[...]`, `list[...]`, etc. What _is_ gramatically valid in such contexts? Seemingly any of the following. (At least, none of the following throw `SyntaxError` in a 3.12.3 REPL.) Generic[x] Generic[*x] Generic[*x, y] Generic[y, *x] Generic[x := 1] Generic[x := 1, y := 2] So introducting flexible_expression: expression | assignment_expression | starred_item end then switching `subscription` to use `flexible_expression` sorts that. But then we need to field `yield` - for which any of the following are apparently valid: yield x yield x, yield x, y yield *x, yield *x, *y Introducing a separate `yield_list` is the simplest way I've been figure out to do this - separating out the special case of `starred_item ,`. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> |
||
---|---|---|
.. | ||
compound_stmts.rst | ||
datamodel.rst | ||
executionmodel.rst | ||
expressions.rst | ||
grammar.rst | ||
import.rst | ||
index.rst | ||
introduction.rst | ||
lexical_analysis.rst | ||
simple_stmts.rst | ||
toplevel_components.rst |