Reference values for exec
garito at gmail.com
Wed Oct 28 15:34:16 CET 2009
Perhaps but the fact is that I need to execute code from some files in the
filesystem and I need to have a common stack for them
2 questions came to my mind:
1.- How can I execute code from files in the filesystem? (I choose exec for
2.- If exec is my only option: how can I use a common stack for them?
2009/10/28 Dave Angel <davea at ieee.org>
> Garito wrote:
>> I'm trying to use exec in a recursive way but I have a problem
>> When I read the manual I understand that the globals and the locals are
>> passed by reference but if I try to use it in a recursive way the new
>> added in a step are not passed to the next one
>> Could someone point me how to do that?
> Post some sample code, and show what doesn't work; maybe you'll get some
> help that way.
> I'll point out just one thing: you cannot add new local variables at
> runtime. locals() should be used to inspect, not to modify.
> See the help text:
> "The contents of this dictionary should not be modified; changes may not
> affect the values of local variables used by the interpreter"
> I have no idea if exec() can be safely called recursively. Most people
> successfully avoid calling it at all.
Mi twitter: http://twitter.com/garito
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list