[Python-bugs-list] [ python-Bugs-223520 ] Example code doesn't work
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 17 Jul 2002 10:39:47 -0700
Bugs item #223520, was opened at 2000-11-26 21:10
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=223520&group_id=5470
Category: Documentation
Group: Not a Bug
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Example code doesn't work
Initial Comment:
In section 4.7.4 the code snippet:
def make_incrementor(n):
return lambda x, incr=n: x+incr
doesn't seem to work. It seems to be returning the lambda function handle instead. This occurred on Win98, using python interactively.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2002-07-17 10:39
Message:
Logged In: NO
This is strange... the sample code in section 4.7.4 at
www.python.org/doc/current/tut/node6.html shows:
def make_incrementor(n):
return lambda x: x + n
which doesn't work. Did the change to add a default
parameter get undone somehow?
Thanks,
Jeremy Weatherford
----------------------------------------------------------------------
Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2000-11-27 07:50
Message:
The doc update is fine, Tim.
If you want me to review something, don't close the bug!
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2000-11-26 22:46
Message:
Not a bug. It's *supposed* to return a (anonymous) function. I added a little more to the tutorial's example (rev 1.121):
>>> def make_incrementor(n):
... return lambda x, incr=n: x+incr
...
>>> f = make_incrementor(42)
>>> f(0)
42
>>> f(1)
43
>>>
Assigned to Fred for doc review, but already closed the bug report.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=223520&group_id=5470