How to pass variables between scripts

Jonathan Smith smithj at rpath.com
Sat May 13 16:35:03 CEST 2006


Gross, Dorit (SDRN) wrote:
 > [snip]
 > for f in fileList:
 >         try:
 >                 globvars = {'infile' : f}
 >                 locvars = {}
 >                 execfile('/scripts/second.py', globvars(), locvars)
 >         except IOError:
 >                 exit(0)
 >         print locvars
 >
 >
 > And this is what happens when calling test_exec.py
 >
 >  ./test_exec.py
 > Traceback (most recent call last):
 >   File "./test_exec.py", line 19, in ?
 >     execfile('/scripts/second.py', vars(), results)
 > TypeError: 'dict' object is not callable
 >

Why do you try to call globevars as if it was a function? As the 
traceback states, dictionaries can't be called like that. Just take the 
() out and try again.

-smithj



More information about the Python-list mailing list