Spawn Python from Python with arguments?

Gary Cramblitt garycramblitt_NOSPAM at comcast.net
Thu Mar 6 22:20:05 EST 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