diff options
author | Tim Peters <tim.peters@gmail.com> | 2000-11-27 06:38:04 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2000-11-27 06:38:04 (GMT) |
commit | c113465a49c042ee9268e0978a31ab2e92b57c1b (patch) | |
tree | 7bf713075a6539181019e076d95b3d2a47cf1c0a /Doc | |
parent | cb54be869c36a04a6e1cb1e964a9e22c37c276c7 (diff) | |
download | cpython-c113465a49c042ee9268e0978a31ab2e92b57c1b.zip cpython-c113465a49c042ee9268e0978a31ab2e92b57c1b.tar.gz cpython-c113465a49c042ee9268e0978a31ab2e92b57c1b.tar.bz2 |
SF non-bug 123520: fleshed out the tutorial's lambda example a little more.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/tut/tut.tex | 11 |
1 files 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} |