python syntax:urgent

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Jan 8 04:44:25 EST 2008


On Tue, 08 Jan 2008 10:03:56 +0100, Jeroen Ruigrok van der Werven wrote:

> -On [20080108 09:42], mpho raborife (mraborife at yahoo.com) wrote:
>>subprocess.Popen(["gmmscore", "-i", Input, "-l", List, "-t",
>> modeltype, "-m", str(mixture), "-d", str(dimension), "-v", str(vfloor),
>> "-n", str(number), "-r", str(results)])
> 
> "gmmscore", "-i" seems a bit silly, why not just "gmmscore -i"?

That's definitely *not* silly but the way to go.  There are two ways: The
above that calls the executable with the arguments as given, or with a
string like you suggests which is interpreted by a shell, so the arguments
must be escaped for that shell.  Which shell?  Depends on the system!

> You can always do something like (assuming all arguments are strings, adjust
> accordingly):
> 
> s = "gmmscore -i %s -l %s -t %s -m %s -d %s -v %s -n %s -r %s" %
>     (Input, List, modeltype, str(mixture), str(dimension), str(vfloor),
>      str(number), str(results))
> 
> subprocess.Popen([s])

Here you are trying to start a program named "gmmscore -i ..." with no
arguments.  That fails (unless you really have a program with that name.  ;-)

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list