From d2d0d70b91c45e6d50709241285221a1a5322bfb Mon Sep 17 00:00:00 2001 From: Sanyam Kumat <124618873+sanyamk23@users.noreply.github.com> Date: Sun, 7 Jun 2026 11:34:06 +0530 Subject: [PATCH] gh-150837: Clarify closure wording in function tutorial Variable lookup uses the local symbol tables of functions enclosing the definition, not the function enclosing the call site. --- Doc/tutorial/controlflow.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 8bac8df4368c00a..b03057425440d01 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -503,12 +503,12 @@ The *execution* of a function introduces a new symbol table used for the local variables of the function. More precisely, all variable assignments in a function store the value in the local symbol table; whereas variable references first look in the local symbol table, then in the local symbol tables of -enclosing functions, then in the global symbol table, and finally in the table -of built-in names. Thus, global variables and variables of enclosing functions -cannot be directly assigned a value within a function (unless, for global -variables, named in a :keyword:`global` statement, or, for variables of enclosing -functions, named in a :keyword:`nonlocal` statement), although they may be -referenced. +functions enclosing the definition, then in the global symbol table, and finally +in the table of built-in names. Thus, global variables and variables of +functions enclosing the definition cannot be directly assigned a value within a +function (unless, for global variables, named in a :keyword:`global` statement, +or, for variables of functions enclosing the definition, named in a +:keyword:`nonlocal` statement), although they may be referenced. The actual parameters (arguments) to a function call are introduced in the local symbol table of the called function when it is called; thus, arguments are