[Python-Dev] Python3 compiled listcomp can't see local var - bug or feature?
skip.montanaro at gmail.com
Mon Jun 11 18:29:37 EDT 2018
> Skip, I think you have misunderstood the point I was making. It was
> not whether the loop variable should leak out of a list comprehension.
> Rather, it was whether a local variable should, so to speak, "leak into"
> a list comprehension. And the answer is: it depends on whether the code
> is executed normally, or via exec/eval.
Got it. Yes, you'll have to pass in locals to exec. (Can't verify, as I'm
on the train, on my phone.) Builtins like range are global to everything,
so no problem there.
Your clarification also make it more of a Python programming question , I
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev