[Python-checkins] python/dist/src/Doc/ref ref6.tex, 1.73.2.3, 1.73.2.4

fdrake@users.sourceforge.net fdrake at users.sourceforge.net
Wed Sep 7 07:18:09 CEST 2005


Update of /cvsroot/python/python/dist/src/Doc/ref
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7497/ref

Modified Files:
      Tag: release24-maint
	ref6.tex 
Log Message:
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)


Index: ref6.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v
retrieving revision 1.73.2.3
retrieving revision 1.73.2.4
diff -u -d -r1.73.2.3 -r1.73.2.4
--- ref6.tex	28 Apr 2005 07:19:39 -0000	1.73.2.3
+++ ref6.tex	7 Sep 2005 05:18:06 -0000	1.73.2.4
@@ -873,7 +873,12 @@
 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}



More information about the Python-checkins mailing list