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 think.