Re: execfile in global scope

2005-08-24 Thread Bengt Richter
On 24 Aug 2005 01:50:25 -0700, [EMAIL PROTECTED] wrote: >I need to execfile() from a function in order to set value for a global >variable from inside the executed file. I know there are "globals" and >"locals" optional arguments for execfile, but I just can't figure out >how to use them correctly

Re: execfile in global scope

2005-08-24 Thread tooper
What about : globdict= globals() def changevar(): global globdict execfile("changevar.py",globdict) x = 111 # global var changevar() print x # returns 111 instead of 555 -- http://mail.python.org/mailman/listinfo/python-list

Re: execfile in global scope

2005-08-24 Thread tooper
What about : globdict= globals() def changevar(): global globdict execfile("changevar.py",globdict) x = 111 # global var changevar() print x # returns 111 instead of 555 -- http://mail.python.org/mailman/listinfo/python-list

execfile in global scope

2005-08-24 Thread v . vayer
I need to execfile() from a function in order to set value for a global variable from inside the executed file. I know there are "globals" and "locals" optional arguments for execfile, but I just can't figure out how to use them correctly. Here is an example: Change.py = x = 555 Main.py =