Python - Execute more programs
Krisztian Kepes
Kepes.Krisztian at peto.hu
Mon Jun 30 08:59:20 EDT 2003
Hi !
I want to start many py programs - with other parameters.
Because the programs have many to-do, I don't want to wait for them.
In Delphi it is like this:
>>>>>>>>>>>>>>>
program startmore;
uses
Windows,
Classes,
SHELLAPI;
var
SL:TStringList;
FileName:string;i:integer;
begin
SL:=TStringList.Create;
try
if (ParamCount<1) then Exit;
SL.LoadFromFile(ParamStr(1));
FileName:=SL[0];
for i:=1 to SL.Count-1 do begin
ShellExecute(0,'open',PChar(FileName),PChar(SL[i]),nil,sw_SHOW);
end;
finally
SL.Free;
end;
end.
In the param (sm.txt) file:
Neurolotto.py
-W1 -S1
-W2 -S1
-W3 -S1
-W4 -S1
-W5 -S1
-W1 -S2
-W2 -S2
-W3 -S2
-W4 -S2
-W5 -S2
-W1 -S3
-W2 -S3
-W3 -S3
-W4 -S3
-W5 -S3
-W1 -S4
-W2 -S4
-W3 -S4
-W4 -S4
-W5 -S4
-W1 -S5
-W2 -S5
-W3 -S5
-W4 -S5
-W5 -S5
startmore.exe sm.txt
The shell is doing his work good, it is find the py -> python.exe assoc., start the py in other cmd window, etc.
But I want to write it in py.
import os
parlist=['-W1 -S1','-W2 -S1' ]
pypath='c:\Python\python.exe'
filename='c:/homedev/neurolotto/bin/v1.0/Neurolotto.py'
for params in parlist:
s='"'+filename+' '+params+'"'
print pypath+' '+s
os.spawnv(os.P_NOWAIT,pypath,[s])
But it is not working. Startfile is seems to good (assoc !), but it is not handle the arguments.
How I do an Delphi compatible but Python based program ?
Thx:
KK
More information about the Python-list
mailing list