[Python-ideas] Explicit variable capture list
David Mertz
mertz at gnosis.cx
Sun Jan 24 01:45:24 EST 2016
On Sat, Jan 23, 2016 at 8:54 AM, Guido van Rossum <guido at python.org> wrote:
> Also, once again the semantics of lambda (specifically, that unlike
>>
> def it doesn't create a scope)
>
>
> Uh, what? I can sort of guess what you are referring to here (namely, that
> no syntactic construct permissible in a lambda can assign to a local
> variable -- or any variable, for that matter).
>
That's not even quite true, you can assign to global variables in a lambda:
>>> myglobal = 1
>>> f = lambda: globals().__setitem__('myglobal', 2) or 42
>>> f()
>>> myglobal
2
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160123/43d47f4b/attachment.html>
More information about the Python-ideas
mailing list