Accessing current namespace's dictionary...
Paul Prescod
paul at prescod.net
Fri Jul 21 16:42:20 EDT 2000
Michael Morrison wrote:
>
> ...
>
> I'm trying to access the module that is running namespace dictionary, but I
> can't seem to find a way to do it.
It's called globals().
>>> globals()["foo"]="bar"
>>> dir()
['__builtins__', '__doc__', '__name__', 'foo']
I'm not sure whether it is a documented feature that it is writable or
not.
--
Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by
marketers who choose not to."
More information about the Python-list
mailing list