Reference values for exec

Garito garito at gmail.com
Wed Oct 28 10:34:16 EDT 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
that)
2.- If exec is my only option: how can I use a common stack for them?

Thanks

2009/10/28 Dave Angel <davea at ieee.org>

> Garito wrote:
>
>> Hi!
>> 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
>> values
>> added in a step are not passed to the next one
>>
>> Could someone point me how to do that?
>>
>> Thanks
>>
>>
>>
> see
> http://www.catb.org/~esr/faqs/smart-questions.html<http://www.catb.org/%7Eesr/faqs/smart-questions.html>
>
> 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.
>
> DaveA
>
>
>


-- 
Mi twitter: http://twitter.com/garito
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091028/454f1fc1/attachment-0001.html>


More information about the Python-list mailing list