changing local dictionnary for functions

Boris Boutillier boris at cantal.lip6.fr
Mon Apr 8 12:45:23 EDT 2002


To be more precise, I'm looking for this kind of function :
execfunction(func,*args,globals,locals)

func is a function
*args : is a list of arguments to pass to the function
globals is a dictionnary (or subclass of it) being used as global dict
locals is a dictionnary (or subclass of it) being used as local dict

I think this kind of function can be written by playing with the
func.func_code bytecode, but before trying to do it this way I'd like to
be sure there is no simple way to do it.

Boris


On Mon, 08 Apr 2002 18:15:31 +0200, Boris Boutillier wrote:

> Is there a way to pass a local dictionnary to a function as it is
> possible to do with a file with the execfile statement ?
> 
> In the python reference manual, in the section 4.1 : Code
> Blocks,execution frames and namespace, there is a table that say that
> function body uses globals namespace of the containing block and a new
> locals namespace. And there is a note that say global and local can be
> overrident, how is it possible ? I think it would be the answer to my
> first question.
> 
> Boris



More information about the Python-list mailing list