]> granicus.if.org Git - python/commitdiff
Document general mappings for the locals argument for exec and execfile().
authorRaymond Hettinger <python@rcn.com>
Tue, 3 Aug 2004 05:17:58 +0000 (05:17 +0000)
committerRaymond Hettinger <python@rcn.com>
Tue, 3 Aug 2004 05:17:58 +0000 (05:17 +0000)
Doc/lib/libfuncs.tex
Doc/ref/ref6.tex

index b3d3d30b458ccc96f3f196612f0c7f719600d0be..ec6a66c58a8e334bf360d708627883c8b1e13308 100644 (file)
@@ -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
index a389176eee0328dc8ec075fa1fef125fc56d2eaa..1017acaa4767d381bf5d02c35a08f218fae13149 100644 (file)
@@ -873,8 +873,9 @@ In all cases, if the optional parts are omitted, the code is executed
 in the current scope.  If only the first expression after \keyword{in}
 is specified, it should be a dictionary, which will be used for both
 the global and the local variables.  If two expressions are given,
-both must be dictionaries and they are used for the global and local
-variables, respectively.
+they are used for the global and local variables, respectively.
+If provided, \var{locals} can be any mapping object.
+\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4}
 
 As a side effect, an implementation may insert additional keys into
 the dictionaries given besides those corresponding to variable names