From c113465a49c042ee9268e0978a31ab2e92b57c1b Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Mon, 27 Nov 2000 06:38:04 +0000 Subject: SF non-bug 123520: fleshed out the tutorial's lambda example a little more. --- Doc/tut/tut.tex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex index ae835cd..87c7a9a 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} -- cgit v0.12