]> granicus.if.org Git - python/commitdiff
SF non-bug 123520: fleshed out the tutorial's lambda example a little more.
authorTim Peters <tim.peters@gmail.com>
Mon, 27 Nov 2000 06:38:04 +0000 (06:38 +0000)
committerTim Peters <tim.peters@gmail.com>
Mon, 27 Nov 2000 06:38:04 +0000 (06:38 +0000)
Doc/tut/tut.tex

index ae835cd43f1ef163a845d69c9ebd2ea1d1c0ede2..87c7a9a204c854139d0c3d575bba137b3b3f36b5 100644 (file)
@@ -1497,8 +1497,15 @@ cannot reference variables from the containing scope, but this can be
 overcome through the judicious use of default argument values, e.g.
 
 \begin{verbatim}
-def make_incrementor(n):
-    return lambda x, incr=n: x+incr
+>>> def make_incrementor(n):
+...     return lambda x, incr=n: x+incr
+...
+>>> f = make_incrementor(42)
+>>> f(0)
+42
+>>> f(1)
+43
+>>>
 \end{verbatim}