exec src in {}, {} strangeness
Stefan Seefeld
seefeld at sympatico.ca
Mon Mar 21 11:28:04 EST 2005
Do Re Mi chel La Si Do wrote:
> Hi !
>
>
> Try :
>
> exec f in globals(),locals()
> or
> exec(f,globals(),locals())
> or
> exec f in globals(),globals()
> or
> exec(f,globals(),globals())
Indeed, using 'globals()' and 'locals()' works. However,
both report the same underlaying object, which is a bit
confusing. (Under what circumstances does 'locals()' return
not the same object as 'globals()' ?)
The problem appears to be that
exec f in a, b
where a and b are distinct dictionaries, does not look up
symbols in 'a' when in local scope.
I filed a bug report (#1167300).
Regards,
Stefan
More information about the Python-list
mailing list