Re: [Python-Dev] Inconsistent nesting of scopes in exec(..., locals())

2010-04-24 Thread Nick Coghlan
Joachim B Haga wrote: >> Since changing this would break class definitions, that ain't going to >> happen. Suggestions for how to explain the behaviour more clearly in the >> exec() documentation probably wouldn't hurt though. > > I don't quite see how exec() affects the class definition syntax?

Re: [Python-Dev] Inconsistent nesting of scopes in exec(..., locals())

2010-04-23 Thread Joachim B Haga
Nick Coghlan writes: > Joachim B Haga wrote: >> There seem to be an inconsistency in the handling of local scopes in >> exec. [...] >> >> The intermediate scope is searched for the variable name if the third >> argument to exec() is locals(), but not if it is locals().copy(). > > What actually m

Re: [Python-Dev] Inconsistent nesting of scopes in exec(..., locals())

2010-04-23 Thread Nick Coghlan
Joachim B Haga wrote: > There seem to be an inconsistency in the handling of local scopes in > exec. Consider the following code, which raises NameError if the '#' is > removed from the second last line. > > > block = """ > b = 'ok' > def f(): > print(b)# raises NameError here > f() > """