I have the following script that will run each script (sequentially) in a directory:
import os directory = [] for dirpath, dirnames, filenames in os.walk(\
You can use the locals argument of execfile(). Write the scripts like this:
def run_script(): ret_value = 2 return ret_value script_ret = run_script()
And in your main script:
script_locals = dict() execfile("path/to/script", dict(), script_locals) print(script_locals["script_ret"])