Python - Execute more programs

Sorry for py question, but I don't have an full-python mailing list's address...

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

Hi all,
i want to use matlab with python 2.2. i first let it run with python 2.0. it
was ok. but now with 2.2 it is not ok. it can not find module pymat (it does
not exist it says).
i set the path in the windows environment and downloaded from:
http://claymore.engineer.gvsu.edu/~steriana/Python/
the pymat22.zip file.
what am i doing wrong?

help!

regards,

stephan

stephan huijgen wrote:

Hi all,
i want to use matlab with python 2.2. i first let it run with python 2.0. it

...

Stephan,

if you want to do matlab-type things in Python, you might be able to avoid this problem by using the Numeric module instead - it provides much matlab-like functionality.

sorry I can't help you more otherwise..

Shi.

yes maybe, but i have to run some matlab m-files from python..

stephan

···

----- Original Message -----
From: "Shi Sherebrin" <shi@imaging.robarts.ca>
To: <wxPython-users@lists.wxwindows.org>
Sent: Monday, June 30, 2003 5:40 PM
Subject: Re: [wxPython-users] Python 2.2 & matlab

stephan huijgen wrote:
> Hi all,
> i want to use matlab with python 2.2. i first let it run with python

2.0. it

...

Stephan,

if you want to do matlab-type things in Python, you might be able to
avoid this problem by using the Numeric module instead - it provides
much matlab-like functionality.

sorry I can't help you more otherwise..

Shi.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

stephan huijgen wrote:

Hi all,
i want to use matlab with python 2.2. i first let it run with python 2.0. it
was ok. but now with 2.2 it is not ok. it can not find module pymat (it does
not exist it says).
i set the path in the windows environment and downloaded from:
http://claymore.engineer.gvsu.edu/~steriana/Python/
the pymat22.zip file.
what am i doing wrong?

You problem is that you asked about non-wxPython software on the wxPython-users list. You should instead ask the author of PyMat, or its users maillist if there is one.

But if I had to guess it would be that you didn't install pymat in a directory that is on the sys.path...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Krisztian Kepes wrote:

Sorry for py question, but I don't have an full-python mailing list's address...

http://www.python.org/psa/MailingLists.html

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 ?

You're executing python.exe but giving it a single parameter that is the .py file and its arg, so Python will be looking for a file named "c:/homedev/neurolotto/bin/v1.0/Neurolotto.py -W1 -S1". Instead you should pass each arg separately. Plus, IIRC you need to pass the commandpath again in the first arg (so it can be argv[0] in the executed program.) Try this:

  args = [pypath, filename] + params.split()
  os.spawnv(os.P_NOWAIT, pypath args)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!