diff options
author | Guido van Rossum <guido@python.org> | 1993-10-18 17:59:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-10-18 17:59:42 (GMT) |
commit | a75d306e2b799aa891666899ca973bec82b2362b (patch) | |
tree | 47ac40c06d5483ca4ed5fed7ee716168a8fe6d6f /Doc/ref6.tex | |
parent | db3165e6559c6b83373e7fed9cdf4371552a9a8e (diff) | |
download | cpython-a75d306e2b799aa891666899ca973bec82b2362b.zip cpython-a75d306e2b799aa891666899ca973bec82b2362b.tar.gz cpython-a75d306e2b799aa891666899ca973bec82b2362b.tar.bz2 |
"exec" is now a statement. execfile() is obsolete.
(Also added a stub for "access".)
Diffstat (limited to 'Doc/ref6.tex')
-rw-r--r-- | Doc/ref6.tex | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Doc/ref6.tex b/Doc/ref6.tex index cb257a3..086d49b 100644 --- a/Doc/ref6.tex +++ b/Doc/ref6.tex @@ -17,6 +17,8 @@ simple_stmt: expression_stmt | continue_stmt | import_stmt | global_stmt + | access_stmt + | exec_stmt \end{verbatim} \section{Expression statements} @@ -466,3 +468,40 @@ definition, function definition, or \verb\import\ statement. restrictions, but programs should not abuse this freedom, as future implementations may enforce them or silently change the meaning of the program.) + +\section{The {\tt access} statement} \label{access} +\stindex{access} + +\begin{verbatim} +access_stmt: "access" ... +\end{verbatim} + +This statement will be used in the future to control access to +instance and class variables. Currently its syntax and effects are +undefined; however the keyword \verb\access\ is a reserved word for +the parser. + +\section{The {\tt exec} statement} \label{exec} +\stindex{exec} + +\begin{verbatim} +exec_stmt: "exec" expression ["in" expression ["," expression]] +\end{verbatim} + +This statement supports dynamic execution of Python code. The first +expression should evaluate to either a string, an open file object, or +a code object. If it is a string, the string is parsed as a suite of +Python statements which is then executed (unless a syntax error +occurs). If it is an open file, the file is parsed until EOF and +executed. If it is a code object, it is simply executed. + +In all cases, if the optional parts are omitted, the code is executed +in the current scope. If only the first expression after \verb\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. + +Note: dynamic evaluation of expressions is supported by the built-in +function \verb\eval\. + |