[Python-Dev] exec/with thunk-handling proposal

Jeff Epler jepler@unpythonic.net
Tue, 4 Feb 2003 08:01:19 -0600


On Tue, Feb 04, 2003 at 01:07:37PM -0000, Moore, Paul wrote:
> And as far as the local namespace is concerned, consider
> 
>     exec something() with f1=12:
>         suite
>     # Out of the exec now - what is the value of f1???
> 
> I assume that the assignment to f1 is still in existence, otherwise you're
> inventing a new way of defining a scope. But if the binding to f1 does still
> exist, then that looks odd, because "exec ... with f1=12" *reads* as if f1 is
> only in scope for the duration of the statement. You seem to lose either
> way...

But Python already has this "problem":
    for i in range(5): pass
    print i

(What's more, 'i' will have a different value than 'i' in the
"equivalent" C fragment
    int i;
    for(i=0; i<5; i++) /*NOTHING*/;
    printf("%d\n", i);
)

But this doesn't seem to bother anybody.  Does it?

Jeff