[issue43605] Issue of scopes unclear in documentation, or wrongly implemented

2021-03-24 Thread Cong Ma
Cong Ma 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 ``NameE

[issue43605] Issue of scopes unclear in documentation, or wrongly implemented

2021-03-23 Thread Bruno Loff
New submission from Bruno Loff : Python 3.9.2 seems to be giving me some unexpected difficulty evaluating generators inside evals. Here is the example: ```python def func(l): def get(i): return l[i] print(sum(get(i) for i in range(len(l # works as expected, prints 10