Spawn Python from Python with arguments?

Gary Cramblitt garycramblitt_NOSPAM at
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", "", "argument1", "argument2"]
    pid = os.spawnv(os.P_NOWAIT, cmd, args) runs, but within it, sys.argv[1] raises exception.

Typing following commmand at terminal prompt works as expected:

    python argument1 argument2


    args = ["python", "", "-c", "argument1", "argument2"]

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

More information about the Python-list mailing list