Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
encukou merged 26 commits intopython:mainfromYash-Vijay29:fix-for-stmt-docs
May 21, 2025
Merged
Changes from1 commit
Commits
Show all changes
26 commits
Select commitHold shift + click to select a range
6873af5
doc: clarify for_stmt grammar by replacing starred_list with expressi…
Yash-Vijay29May 15, 2025
3795065
star_expressions
Yash-Vijay29May 15, 2025
02c6d47
Merge branch 'main' into fix-for-stmt-docs
Yash-Vijay29May 15, 2025
1152b1b
star_expressions
Yash-Vijay29May 15, 2025
9967ec9
star_expressions
Yash-Vijay29May 15, 2025
9442bf8
doc: clarify for_stmt grammar by replacing starred_list with expressi…
Yash-Vijay29May 15, 2025
c9abb45
star_expressions
Yash-Vijay29May 15, 2025
ec6005b
star_expressions
Yash-Vijay29May 15, 2025
e760500
star_expressions
Yash-Vijay29May 15, 2025
b8beb7d
star_expressions
Yash-Vijay29May 16, 2025
7f53e8b
Merge remote-tracking branch 'origin/fix-for-stmt-docs' into fix-for-…
Yash-Vijay29May 16, 2025
e908fce
Update compound_stmts.rst
Yash-Vijay29May 16, 2025
50f1e09
Update compound_stmts.rst
Yash-Vijay29May 16, 2025
8e860fa
Update compound_stmts.rst
Yash-Vijay29May 16, 2025
0866ba2
Update compound_stmts.rst
Yash-Vijay29May 16, 2025
27c94a6
Update compound_stmts.rst
Yash-Vijay29May 16, 2025
99c40ff
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
a448548
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
32e1ee1
Merge branch 'python:main' into fix-for-stmt-docs
Yash-Vijay29May 18, 2025
cab198f
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
5b1fad3
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
a4839cb
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
9af4d49
Update compound_stmts.rst
Yash-Vijay29May 18, 2025
0ef3fb7
Merge branch 'main' into fix-for-stmt-docs
Yash-Vijay29May 20, 2025
5ce932e
Update compound_stmts.rst
Yash-Vijay29May 21, 2025
0417261
Update compound_stmts.rst
Yash-Vijay29May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
doc: clarify for_stmt grammar by replacing starred_list with expressi…
…on_list
  • Loading branch information
@Yash-Vijay29
Yash-Vijay29 committedMay 15, 2025
commit6873af503a42a935cb49ce2f39a5c77afec1fb6f
19 changes: 10 additions & 9 deletionsDoc/reference/compound_stmts.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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:
(such as a string, tuple, or list) or other iterable object:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please see warnings on your pr.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The 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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The 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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why this comma? Seems unrelated to the pr content.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why this comma? Seems unrelated to the pr content.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@StanFromIreland, does this looks correct for you?

Copy link
Contributor

Choose a reason for hiding this comment

The 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" `starred_list` ":" `suite`
for_stmt: "for" `target_list` "in" `expression_list` ":" `suite`
: ["else" ":" `suite`]

The ``starred_list`` expression 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,
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
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp