Spawn Python from Python with arguments?
Gary Cramblitt
garycramblitt_NOSPAM at comcast.net
Sun Mar 9 11:48:00 EST 2003
On Thu, 06 Mar 2003 22:20:05 +0000, Gary Cramblitt wrote:
> 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?
I was able to fix this myself by changing spawnv to spawnvp.
More information about the Python-list
mailing list