mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Document general mappings for the locals argument for exec and execfile().
This commit is contained in:
parent
a57ec93b93
commit
70fcdb8be0
2 changed files with 11 additions and 9 deletions
|
|
@ -343,13 +343,14 @@ class C:
|
|||
and does not create a new module.\footnote{It is used relatively
|
||||
rarely so does not warrant being made into a statement.}
|
||||
|
||||
The arguments are a file name and two optional dictionaries. The
|
||||
file is parsed and evaluated as a sequence of Python statements
|
||||
(similarly to a module) using the \var{globals} and \var{locals}
|
||||
dictionaries as global and local namespace. If the \var{locals}
|
||||
dictionary is omitted it defaults to the \var{globals} dictionary.
|
||||
If both dictionaries are omitted, the expression is executed in the
|
||||
environment where \function{execfile()} is called. The return value is
|
||||
The arguments are a file name and two optional dictionaries. The file is
|
||||
parsed and evaluated as a sequence of Python statements (similarly to a
|
||||
module) using the \var{globals} and \var{locals} dictionaries as global and
|
||||
local namespace. If provided, \var{locals} can be any mapping object.
|
||||
\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
|
||||
If the \var{locals} dictionary is omitted it defaults to the \var{globals}
|
||||
dictionary. If both dictionaries are omitted, the expression is executed in
|
||||
the environment where \function{execfile()} is called. The return value is
|
||||
\code{None}.
|
||||
|
||||
\warning{The default \var{locals} act as described for function
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue