exec src in {}, {} strangeness

Peter Hansen peter at engcorp.com
Mon Mar 21 11:47:26 EST 2005


Stefan Seefeld wrote:
> 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()' ?)

When you aren't at the interactive prompt...  there are
no "locals" there, so locals() just maps through to globals().
(Probably this applies to all code at the module level,
as oppsed to code inside any callable, but I haven't
verified... you can easily enough.)

Does this information invalidate your bug report?

-Peter



More information about the Python-list mailing list