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

Guido van Rossum (Guido.van.Rossum@cwi.nl)
Tue, 04 Aug 1992 21:49:09 +0200

Jaap Vermeulen writes:
>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.

You cannot do that, and in a future version of Python the local
namespace of a function may not be implemented as a dictionary.
I played a little with implementing it as a mutable tuple, indexed by
variable number, and it makes an awful lot of difference in execution
speed. (Unfortunately there are a lot of minor things to be cleared up
before this can be used in general, and it won't be in the next
release.)

Why do you the want to access local namespace?

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"Do you want to have just one argument or were you thinking of taking
a course?"
[Sorry for the duplicate message Jaap, I must train my fingers :-) ]