Skip to content

Commit 7842aed

Browse files
bpo-45619: documentation of execution model: clarify and update binding summary (GH-29232)
This does two changes that are quite related. 0. it add that variable binding can occur in pattern matching, an update of 3.10 which seems to have been omitted from the list of bindings 1. Given how long the sentence already was, with even subcases in the middle of the sentence, the commit breaks the sentence into an actual list. (cherry picked from commit cd876c8) Co-authored-by: Arthur Milchior <[email protected]>
1 parent 3f565f8 commit 7842aed

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

Doc/reference/executionmodel.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,25 @@ Binding of names
5656

5757
.. index:: single: from; import statement
5858

59-
The following constructs bind names: formal parameters to functions,
60-
:keyword:`import` statements, class and function definitions (these bind the
61-
class or function name in the defining block), and targets that are identifiers
62-
if occurring in an assignment, :keyword:`for` loop header, or after
63-
:keyword:`!as` in a :keyword:`with` statement or :keyword:`except` clause.
64-
The :keyword:`!import` statement
65-
of the form ``from ... import *`` binds all names defined in the imported
66-
module, except those beginning with an underscore. This form may only be used
67-
at the module level.
59+
The following constructs bind names:
60+
61+
* formal parameters to functions,
62+
* class definitions,
63+
* function definitions,
64+
* assignment expressions,
65+
* :ref:`targets <assignment>` that are identifiers if occurring in
66+
an assignment:
67+
68+
+ :keyword:`for` loop header,
69+
+ after :keyword:`!as` in a :keyword:`with` statement, :keyword:`except`
70+
clause or in the as-pattern in structural pattern matching,
71+
+ in a capture pattern in structural pattern matching
72+
73+
* :keyword:`import` statements.
74+
75+
The :keyword:`!import` statement of the form ``from ... import *`` binds all
76+
names defined in the imported module, except those beginning with an underscore.
77+
This form may only be used at the module level.
6878

6979
A target occurring in a :keyword:`del` statement is also considered bound for
7080
this purpose (though the actual semantics are to unbind the name).

0 commit comments

Comments
 (0)