This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients christian.heimes, vincent7f
Date 2021-10-14.12:53:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634216000.95.0.175671075801.issue45469@roundup.psfhosted.org>
In-reply-to
Content
You are running in a typical scope issue. The local and global scope of a lambda work differently than you expect. You can work around the issue by making fun a local variable:

for name, fun in namefun:
    name2fun[name] = lambda x, fun=fun: fun(x)
History
Date User Action Args
2021-10-14 12:53:20christian.heimessetrecipients: + christian.heimes, vincent7f
2021-10-14 12:53:20christian.heimessetmessageid: <1634216000.95.0.175671075801.issue45469@roundup.psfhosted.org>
2021-10-14 12:53:20christian.heimeslinkissue45469 messages
2021-10-14 12:53:20christian.heimescreate