diff options
author | Fred Drake <fdrake@acm.org> | 2001-12-03 21:47:37 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-12-03 21:47:37 (GMT) |
commit | fcf94681ed3562277a0d5c4faab226b0d69c2d79 (patch) | |
tree | 5e2418972dd215144902f3a6f7782e3d793b0b95 /Doc/tut/tut.tex | |
parent | 1a76386194964955f1c72a1d39a55fa19680555a (diff) | |
download | cpython-fcf94681ed3562277a0d5c4faab226b0d69c2d79.zip cpython-fcf94681ed3562277a0d5c4faab226b0d69c2d79.tar.gz cpython-fcf94681ed3562277a0d5c4faab226b0d69c2d79.tar.bz2 |
Update lambda description to reflect nested scopes. This was noted by
Andrew Koenig.
Diffstat (limited to 'Doc/tut/tut.tex')
-rw-r--r-- | Doc/tut/tut.tex | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index dfa71fe..e90c267 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -1535,19 +1535,17 @@ Here's a function that returns the sum of its two arguments: objects are required. They are syntactically restricted to a single expression. Semantically, they are just syntactic sugar for a normal function definition. Like nested function definitions, lambda forms -cannot reference variables from the containing scope, but this can be -overcome through the judicious use of default argument values: +can reference variables from the containing scope: \begin{verbatim} >>> def make_incrementor(n): -... return lambda x, incr=n: x+incr +... return lambda x: x + n ... >>> f = make_incrementor(42) >>> f(0) 42 >>> f(1) 43 ->>> \end{verbatim} |