[Python-Dev] Python3 compiled listcomp can't see local var - bug or feature?

Skip Montanaro 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...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180611/76e3d202/attachment.html>

More information about the Python-Dev mailing list