[python-win32] Apologies - Spawn problem

John Machin sjmachin at lexicon.net
Tue Jan 31 23:36:03 CET 2006


Frank Peacock wrote:
> Hello again
> 
> I need to correct the previous email. The correct main.py file is attached
> now.
> 
> The interesting thing is that the naming of the python file does not change
> the result.
> 
> The result always is output to the screen: "Main" and then "Exit", there is
> no "subprocess" outputted.
> 

I'm not about to dump odd files into my root directory; I can't 
reproduce your symptoms using a sub-directory ... see below.
I'm running Win XP Pro SP2; yours is what?
Why are you still running Python 2.1???
BTW, print is not a function, it's a statement.
You should get out of the backslashitis habit 
('c:\python21\\python.exe') very quickly. Apart from the fact that for 
consistency you should have had 'c:\\python21\\python.exe', it is much 
easier to compose and read r'c:\python21\python.exe'.

HTH,
John

C:\junk>type main.py
# Main script
import os

print("main")

os.spawnv(os.P_WAIT, 
'c:\python21\\python.exe',('python.exe','c:\\subprocess.py'
))

print("exit")
C:\junk>type subprocess.py
import sys
print "subprocess", sys.argv

C:\junk>type main2.py
# Main script
import os

print "main"

os.spawnv(
     os.P_WAIT,
     'c:\python21\\python.exe',
     ('"just about any old rubbish"', 'c:\\junk\\subprocess.py',)
     )

print "exit"

**** running main with Python 2.4.2
**** got IDENTICAL results with 2.1.3
**** (by doing c:\python21\python main*.py)
C:\junk>python main.py
main
python.exe: can't open file 'c:\subprocess.py'
exit

C:\junk>python main2.py
main
subprocess ['c:\\junk\\subprocess.py']
exit

C:\junk>



More information about the Python-win32 mailing list