summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2005-09-07 05:18:06 (GMT)
committerFred Drake <fdrake@acm.org>2005-09-07 05:18:06 (GMT)
commitd7390a8de7c397d74843e749630b3f4f1b6a7d67 (patch)
tree0e9dca742c1fad9e90b3c2ff07b723d84c281176
parent112255b4596849507984558383856f14bd075b77 (diff)
downloadcpython-d7390a8de7c397d74843e749630b3f4f1b6a7d67.zip
cpython-d7390a8de7c397d74843e749630b3f4f1b6a7d67.tar.gz
cpython-d7390a8de7c397d74843e749630b3f4f1b6a7d67.tar.bz2
note that the return and yield statements cannot be used at the top level in
exec statements; people coming from certain other languages seem to be confused by this on a regular basis (backported from trunk revision 1.77)
-rw-r--r--Doc/ref/ref6.tex7
1 files changed, 6 insertions, 1 deletions
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index 6698f46..b1389e0 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -873,7 +873,12 @@ 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.
+executed. If it is a code object, it is simply executed. In all
+cases, the code that's executed is expected to be be valid as file
+input (see section~\ref{file-input}, ``File input''). Be aware that
+the \keyword{return} and \keyword{yield} statements may not be used
+outside of function definitions even within the context of code passed
+to the \keyword{exec} statement.
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}