Spawn Python from Python with arguments?

Gary Cramblitt garycramblitt_NOSPAM at comcast.net
Fri Mar 7 04:20:05 CET 2003


I'm trying to run another python program from python and pass command line
arguments to the spawned python program.

    cmd = "python"
    args = ["python", "child.py", "argument1", "argument2"]
    pid = os.spawnv(os.P_NOWAIT, cmd, args)

child.py runs, but within it, sys.argv[1] raises exception.

Typing following commmand at terminal prompt works as expected:

    python child.py argument1 argument2

and

    args = ["python", "child.py", "-c", "argument1", "argument2"]

doesn't help.  Anybody know how to do this?






More information about the Python-list mailing list