Re: how to pass the workspace ?

2008-03-14 Thread Stef Mientki
Thanks, Gary and Dennis,

Dennis Lee Bieber wrote:
> On Thu, 13 Mar 2008 21:35:42 +0100, Stef Mientki
> <[EMAIL PROTECTED]> 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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass the workspace ?

2008-03-13 Thread Stef Mientki
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
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass the workspace ?

2008-03-11 Thread Gary Herron
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

Gary Herron

-- 
http://mail.python.org/mailman/listinfo/python-list


how to pass the workspace ?

2008-03-11 Thread Stef Mientki
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
-- 
http://mail.python.org/mailman/listinfo/python-list