Cong Ma <[email protected]> added the comment:
I think this is in the same class of behaviours as
```
def func(l):
def get(i):
return l[i]
print(eval("(lambda x: get(x))(0)")) # Call anonymous lambda with the
constant 0 as argument
```
Calls like ``func(["spam"])`` will not "work", and ``NameError`` is raised.
In this case, inside the lambda's body the name "get" can't be resolved. For
the lambda body, the name "get" is a nonlocal but there's no way to access a
nonlocal in a lambda.
The comprehensions, like lambdas, are in their own nested scope.
----------
nosy: +congma
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43605>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com