@@ -873,9 +873,13 @@ primary is subscripted, the evaluated result of the expression list will be
873
873
passed to one of these methods. For more details on when ``__class_getitem__ ``
874
874
is called instead of ``__getitem__ ``, see :ref: `classgetitem-versus-getitem `.
875
875
876
- If the expression list contains at least one comma, it will evaluate to a
877
- :class: `tuple ` containing the items of the expression list. Otherwise, the
878
- expression list will evaluate to the value of the list's sole member.
876
+ If the expression list contains at least one comma, or if any of the expressions
877
+ is starred, the expression list will evaluate to a :class: `tuple ` containing the
878
+ items of the expression list. Otherwise, the expression list will evaluate to
879
+ the value of the list's sole member.
880
+
881
+ .. versionchanged :: 3.11
882
+ Expressions in an expression list may be starred. See :pep: `646 ` for details.
879
883
880
884
For built-in objects, there are two types of objects that support subscription
881
885
via :meth: `~object.__getitem__ `:
@@ -1874,7 +1878,7 @@ Expression lists
1874
1878
single: , (comma); expression list
1875
1879
1876
1880
.. productionlist :: python-grammar
1877
- expression_list: `expression ` ("," `expression `)* [","]
1881
+ expression_list: `starred_expression ` ("," `starred_expression `)* [","]
1878
1882
starred_list: `starred_item ` ("," `starred_item `)* [","]
1879
1883
starred_expression: `expression ` | (`starred_item ` ",")* [`starred_item `]
1880
1884
starred_item: `assignment_expression ` | "*" `or_expr `
@@ -1898,6 +1902,9 @@ the unpacking.
1898
1902
.. versionadded :: 3.5
1899
1903
Iterable unpacking in expression lists, originally proposed by :pep: `448 `.
1900
1904
1905
+ .. versionadded :: 3.11
1906
+ Any item in an expression list may be starred. See :pep: `646 `.
1907
+
1901
1908
.. index :: pair: trailing; comma
1902
1909
1903
1910
A trailing comma is required only to create a one-item tuple,
0 commit comments