dynamic creation of global Identifier

Theerasak Photha hanumizzle at gmail.com
Wed Oct 11 05:17:47 EDT 2006


On 10/11/06, Alexander Eisenhuth <newsuser at stacom-software.de> wrote:

> but why doesent exec "global ... create a identifier in the global namespace.

I haven't had much use for exec, but it operates in its own, more or
less cloistered namespace. It can't set globals among other things.

You can frob the globals like so

import __builtin__
__builtin__.__dict__['foo'] = 42

But by the time you get there, it is almost certainly time to refactor.

-- Theerasak



More information about the Python-list mailing list