how to pass the workspace ?

Stef Mientki stef.mientki at gmail.com
Fri Mar 14 05:32:11 EDT 2008


Thanks, Gary and Dennis,

Dennis Lee Bieber wrote:
> On Thu, 13 Mar 2008 21:35:42 +0100, Stef Mientki
> <stef.mientki at gmail.com> declaimed the following in comp.lang.python:
>
>
>   
>> The result of globals and locals in the file is eaxctly the same and 
>> none of them mentions 'NewVar' and 'beer'
>> The result of tree_globs and tree_locals is exactly the same and both 
>> doesn't contain 'NewVar' and 'beer'
>> Maybe it's very simple after reading the manual,
>> but apperently I'm missing the essential clue.
>> What am I missing ?
>>
>>     
> 	Use of globals() and locals() vs globals and locals?
>   
Well I get an error with that.
But you both give me some ideas, and it's working now:
- I don't need the locals
- from the file where the execute is launched, you must use the normal 
dictionary call

     tree_globs = {}
     tree_globs [ 'NewVar' ] = 24
     filename = self.Get_Editor_Filename (nodename)
     execfile ( filename, tree_globs )
     print self.tree_globs['NewVar']
     print self.tree_globs['beer']

where the code in the executed file is:

beer = 'testje'

the output I get is:

24
testje

and the "self.tree_globs" travels perfectly though all the files executed.

cheers,
Stef



More information about the Python-list mailing list