[issue43605] Eval/exec and comprehension scopes unclear in documentation

2021-03-27 Thread Bruno Loff
Bruno Loff added the comment: Hmm yes, some more words in the documentation might help. Does anyone understand why it happens, though? Specifically, note that sum(get(i) for i in range(len(l))) or eval("get(0) + get(1) + get(2) + get(3)") or eval("sum(get(i) for i

[issue43605] Eval/exec and comprehension scopes unclear in documentation

2021-03-26 Thread Bruno Loff
Bruno Loff added the comment: Hmm... OK, if I understand correctly, the evaluation procedure for a (e.g.) list comprehension, as described in the documentation you linked in, is as follows: * The generator in the leftmost for expression is evaluated in the current local scope. (doc

[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