Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-134026: Fix grammar description of for statement#134034
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
6873af5
3795065
02c6d47
1152b1b
9967ec9
9442bf8
c9abb45
ec6005b
e760500
b8beb7d
7f53e8b
e908fce
50f1e09
8e860fa
0866ba2
27c94a6
99c40ff
a448548
32e1ee1
cab198f
5b1fad3
a4839cb
9af4d49
0ef3fb7
5ce932e
0417261
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
…on_list
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -151,21 +151,22 @@ The :keyword:`!for` statement | ||
single: : (colon); compound statement | ||
The :keyword:`for` statement is used to iterate over the elements of a sequence | ||
(such as a string, tuple, or list) or other iterable object: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Please see warnings on your pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. okay yea saw it. found a "starred_expression_list" in thehttps://docs.python.org/3/reference/expressions.html#grammar-token-python-grammar-starred_expression_list. I will try to link it to that instead then There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @skirpichev done, i reviewed it locally and doc seems proper. starred_list is turned into starred_expression_list mentioned already inhttps://docs.python.org/3/reference/expressions.html#grammar-token-python-grammar-starred_expression_list There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why this comma? Seems unrelated to the pr content. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
While changing i just noticed a small grammar error and thought of fixing it. Its a small mistake but comma should be there after the tuple, I can make a separate PR for it if you want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @StanFromIreland, does this looks correct for you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It is anoxford comma, its usage is varied across contexts, but generally recommended in formal writing. It is unrelated to this pr and not very important, I am not against it staying, but I wouldn't be heavily opposed to removing it either. | ||
.. productionlist:: python-grammar | ||
for_stmt: "for" `target_list` "in" `expression_list` ":" `suite` | ||
: ["else" ":" `suite`] | ||
The ``expression_list`` is evaluated once; it should yield an :term:`iterable` object. | ||
An :term:`iterator` is created for that iterable. The first item provided by the iterator | ||
is then assigned to the target list using the standard rules for assignments | ||
(see :ref:`assignment`), and the suite is executed. This repeats for each item provided | ||
by the iterator. When the iterator is exhausted, the suite in the :keyword:`!else` clause, | ||
if present, is executed, and the loop terminates. | ||
Note that as of Python 3.11, unpacking with starred expressions (e.g., ``*x``) is supported | ||
in the iterable expression list. | ||
.. index:: | ||
pair: statement; break | ||
pair: statement; continue | ||