[Python-bugs-list] [Bug #123520] Example code doesn't work

noreply@sourceforge.net noreply@sourceforge.net
Sun, 26 Nov 2000 22:46:25 -0800


Bug #123520, was updated on 2000-Nov-26 21:10
Here is a current snapshot of the bug.

Project: Python
Category: Documentation
Status: Open
Resolution: None
Bug Group: None
Priority: 5
Summary: Example code doesn't work

Details: 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.

Follow-Ups:

Date: 2000-Nov-26 22:46
By: tim_one

Comment:
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.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=123520&group_id=5470