Skip to content

Commit 87f5e00

Browse files
committed
fixup! bpo-46725: Document starred expressions in for statements
1 parent 4600b91 commit 87f5e00

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Doc/reference/compound_stmts.rst

+2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ the built-in function :func:`range` returns an iterator of integers suitable to
199199
emulate the effect of Pascal's ``for i := a to b do``; e.g., ``list(range(3))``
200200
returns the list ``[0, 1, 2]``.
201201

202+
.. versionchanged:: 3.11
203+
Starred elements are now allowed in the expression list.
202204

203205
.. _try:
204206
.. _except:

Doc/whatsnew/3.11.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ traceback. (Contributed by Irit Katriel in :issue:`45607`.)
160160
Other Language Changes
161161
======================
162162

163-
* Starred expressions can be used in :ref:`for statements<for>`.
163+
* Starred expressions can be used in :ref:`for statements<for>` (See
164+
:issue:`46725` for more details).
164165

165166
* Asynchronous comprehensions are now allowed inside comprehensions in
166167
asynchronous functions. Outer comprehensions implicitly become

Lib/test/test_grammar.py

+6
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,12 @@ def __getitem__(self, i):
13941394
result.append(x)
13951395
self.assertEqual(result, [1, 2, 3])
13961396

1397+
result = []
1398+
a = b = c = [1,2,3]
1399+
for x in *a, *b, *c:
1400+
result.append(x)
1401+
self.assertEqual(result, 3 * a)
1402+
13971403
def test_try(self):
13981404
### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
13991405
### | 'try' ':' suite 'finally' ':' suite

0 commit comments

Comments
 (0)