how to pass the workspace ?

Stef Mientki stef.mientki at gmail.com
Thu Mar 13 16:35:42 EDT 2008


Gary Herron wrote:
> Stef Mientki wrote:
>> hello,
>>
>> I've GUI tree with drag and drop nodes,
>> where each nodes contains a code snippet.
>> Now I want to run one or more branches in that tree,
>> so I enumerate over the nodes and have to run something like this:
>>
>> execfile ( node1 )
>> execfile ( node2 )
>> etc..
>>
>> Now how do I pass the workspace created in node1, to node 2, etc ?
>>
>> thanks,
>> Stef Mientki
>>   
>
> RTFM!  In particular: 
> http://docs.python.org/lib/built-in-funcs.html#l2h-26
thanks Gary, I read that,
but sorry, unfortunately I don't understand it,
this is what I tried:

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

where the code in the executed file is:

beer = 'testje'
print dir()
print dir (globals)
print dir (locals)

the output I get is:

aap

['beer']

['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', 
'__getattribute__', '__hash__', '__init__', '__module__', '__name__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', 
'__setattr__', '__str__']

['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', 
'__getattribute__', '__hash__', '__init__', '__module__', '__name__', 
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__self__', 
'__setattr__', '__str__']

['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', 
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', 
'__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', 
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 
'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 
'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']

['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', 
'__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', 
'__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', 
'__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', 
'__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 
'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 
'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']

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 ?

thanks,
Stef Mientki



More information about the Python-list mailing list