[Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.153,1.154

Fred L. Drake fdrake@users.sourceforge.net
Mon, 03 Dec 2001 13:47:40 -0800


Update of /cvsroot/python/python/dist/src/Doc/tut
In directory usw-pr-cvs1:/tmp/cvs-serv28673/tut

Modified Files:
	tut.tex 
Log Message:
Update lambda description to reflect nested scopes.  This was noted by
Andrew Koenig.


Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.153
retrieving revision 1.154
diff -C2 -d -r1.153 -r1.154
*** tut.tex	2001/12/03 18:54:33	1.153
--- tut.tex	2001/12/03 21:47:37	1.154
***************
*** 1536,1545 ****
  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:
  
  \begin{verbatim}
  >>> def make_incrementor(n):
! ...     return lambda x, incr=n: x+incr
  ...
  >>> f = make_incrementor(42)
--- 1536,1544 ----
  expression.  Semantically, they are just syntactic sugar for a normal
  function definition.  Like nested function definitions, lambda forms
! can reference variables from the containing scope:
  
  \begin{verbatim}
  >>> def make_incrementor(n):
! ...     return lambda x: x + n
  ...
  >>> f = make_incrementor(42)
***************
*** 1548,1552 ****
  >>> f(1)
  43
- >>>
  \end{verbatim}
  
--- 1547,1550 ----