diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-12 00:43:29 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-08-12 00:43:29 (GMT) |
commit | 016880229a369a3fb419f3eed28b6db7c342fe71 (patch) | |
tree | 9b11de5c197bc556dd515e035327673765cd4871 /Doc/howto | |
parent | 41eaedd3613cebc83e6b9925499369992c7a7770 (diff) | |
download | cpython-016880229a369a3fb419f3eed28b6db7c342fe71.zip cpython-016880229a369a3fb419f3eed28b6db7c342fe71.tar.gz cpython-016880229a369a3fb419f3eed28b6db7c342fe71.tar.bz2 |
Kill execfile(), use exec() instead
Diffstat (limited to 'Doc/howto')
-rw-r--r-- | Doc/howto/doanddont.tex | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/howto/doanddont.tex b/Doc/howto/doanddont.tex index 0cd5d91..b54f069 100644 --- a/Doc/howto/doanddont.tex +++ b/Doc/howto/doanddont.tex @@ -81,7 +81,7 @@ There are situations in which \code{from module import *} is just fine: \end{itemize} -\subsection{Unadorned \function{exec}, \function{execfile} and friends} +\subsection{Unadorned \function{exec} and friends} The word ``unadorned'' refers to the use without an explicit dictionary, in which case those constructs evaluate code in the {\em current} environment. @@ -97,7 +97,7 @@ Bad examples: >>> def func(s, **kw): >>> for var, val in kw.items(): >>> exec("s.%s=val" % var) # invalid! ->>> execfile("handler.py") +>>> exec(open("handler.py").read()) >>> handle() \end{verbatim} @@ -111,7 +111,7 @@ Good examples: >>> for var, val in kw.items(): >>> setattr(s, var, val) >>> d={} ->>> execfile("handle.py", d, d) +>>> exec(open("handler.py").read(), d, d) >>> handle = d['handle'] >>> handle() \end{verbatim} |