summaryrefslogtreecommitdiffstats
path: root/Doc/ref/ref7.tex
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-03-23 17:23:50 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-03-23 17:23:50 (GMT)
commitaa90adcfb9ed2d5bed743e18e83489930296bd25 (patch)
treed575195b2cf177bdadef96a5890617f5aeef8747 /Doc/ref/ref7.tex
parent7190247e0b43b5193a00239b209334aa34e70217 (diff)
downloadcpython-aa90adcfb9ed2d5bed743e18e83489930296bd25.zip
cpython-aa90adcfb9ed2d5bed743e18e83489930296bd25.tar.gz
cpython-aa90adcfb9ed2d5bed743e18e83489930296bd25.tar.bz2
Add nested scopes spec to appendix.
Add new opcodes LOAD_CLOSURE, LOAD_DEREF, STORE_DEREF, MAKE_CLOSURE to docs for dis module. Add docs for new function and code members in Sec. 3 of ref manual. They're present regardless of whether nested scopes are used. Remove description of default argument hack from Sec. 7 of the ref manual and refer the reader to the appendix.
Diffstat (limited to 'Doc/ref/ref7.tex')
-rw-r--r--Doc/ref/ref7.tex20
1 files changed, 3 insertions, 17 deletions
diff --git a/Doc/ref/ref7.tex b/Doc/ref/ref7.tex
index b8fac0b..9107fe9 100644
--- a/Doc/ref/ref7.tex
+++ b/Doc/ref/ref7.tex
@@ -364,23 +364,9 @@ allows the execution of multiple statements.
\strong{Programmer's note:} a ``\code{def}'' form executed inside a
function definition defines a local function that can be returned or
-passed around. Because of Python's two-scope philosophy, a local
-function defined in this way does not have access to the local
-variables of the function that contains its definition; the same rule
-applies to functions defined by a lambda form. A standard trick to
-pass selected local variables into a locally defined function is to
-use default argument values, like this:
-
-\begin{verbatim}
-# Return a function that returns its argument incremented by 'n'
-def make_incrementer(n):
- def increment(x, n=n):
- return x+n
- return increment
-
-add1 = make_incrementer(1)
-print add1(3) # This prints '4'
-\end{verbatim}
+passed around. The semantics of name resolution in the nested
+function will change in Python 2.2. See the appendix for a
+description of the new semantics.
\section{Class definitions\label{class}}
\indexii{class}{definition}