[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: python syntax:urgent

Jeroen Ruigrok van der Werven

1/8/2008 9:04:00 AM

-On [20080108 09:42], mpho raborife (mraborife@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"?

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])

--
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
ã?¤ã?§ã?«ã?¼ã?³ ã?©ã?¦ã??ã?­ã??ã?¯ ã?´ã?¡ã?³ ã??ã?« ã?¦ã?§ã?«ã?´ã?§ã?³
http://www.in-n... | http://www.ra...
Few are those who see with their own eyes and feel with their own hearts...
1 Answer

Marc 'BlackJack' Rintsch

1/8/2008 9:44:00 AM

0

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

> -On [20080108 09:42], mpho raborife (mraborife@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