How do I get to the local dictionary in a function?

Jaap Vermeulen (jaap@sequent.com)
Tue, 04 Aug 92 12:28:27 PDT

I would like to pass along the local namespace (dictionary) of a function
into an exec() statement. Either I'm overlooking something or it is
buried somewhere in the manual since I can't seem to find how to do that.
I can get to the global namespace, but not the local.

The problem is that I want to specify the global namespace explicitly.
This defaults to the local namespace being the global namespace, which
is exactly what I do *not* want.

Anybody any clues?

Example:

>>> global_namespace = {}

>>> def showit:
... var_in_local_namespace = 0
... # I wish I could give the local namespace as third argument
... exec ('var_in_local_namespace = 1\n', global_namespace)
... return var_in_local_namespace

>>> showit()
0
>>>

Thanks,

-Jaap-

--
Jaap Vermeulen					+--------------------------+
						| Sequent Computer Systems |
	Internet : jaap@sequent.com		| Beaverton, Oregon	   |
	Uucp	 : ...uunet!sequent!jaap	+--------------------------+