spawnv question

Fredrik Lundh fredrik at
Tue Feb 13 10:48:32 EST 2001

Daniel Klein wrote:
> Here is a snippet of code I'm using with the 'spawnv' command:
> import os
> args = ('', '') # This works
> os.spawnv(os.P_NOWAIT, 'c:\progra~1\intern~1\iexplore', args)
> print "done"
> The Python Reference for the 'spawnv' command says:
>  "Execute the program path in a new process, passing the arguments specified in
> args as command-line parameters. args may be a list or a tuple."
> My question is, why do I have to specify the url argument twice in the 'args'
> variable.

because internet explorer, like any other program, expects to
find its first argument in argv[1], not argv[0].

by convention (and sometimes necessity), the first argument
should be the name of the program's executable.  try this:

    os.spawnv(mode, program, (program,) + tuple(args))

under unix, (program,) should be (os.path.basename(program),)

Cheers /F

More information about the Python-list mailing list