You can run it as a separate process using subprocess.call
or subprocess.Popen
. If you don't want to run it as a child process, then it starts to get more complicated (depending on the structure of your arg.py
script.
execfile
takes the file you pass to it and includes it in the current script -- Much like a #include
pre-processor directive in c/c++ (although this is done dynamically). One really ugly option using execfile
would be:
#completely untested.
import sys
def run_script(script_name,*args):
_argv = sys.argv[:]
sys.argv = list(args)
execfile(script_name)
sys.argv = _argv