From: Tim Peters Date: Mon, 27 Nov 2000 06:38:04 +0000 (+0000) Subject: SF non-bug 123520: fleshed out the tutorial's lambda example a little more. X-Git-Tag: v2.1a1~711 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c113465a49c042ee9268e0978a31ab2e92b57c1b;p=python SF non-bug 123520: fleshed out the tutorial's lambda example a little more. --- diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index ae835cd43f..87c7a9a204 100644 --- a/Doc/tut/tut.tex +++ b/Doc/tut/tut.tex @@ -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}