A problem with subprocess

Albert Hopkins marduk at letterboxes.org
Fri Mar 20 22:24:18 EDT 2009


On Fri, 2009-03-20 at 22:14 -0400, Colin J. Williams wrote:
> Below is a test script:
> 
> # tSubProcess.py
> 
> import subprocess
> import sys
> try:
>    v= subprocess.Popen('ftype 
> py=C:\Python25\Python.exe')
> except WindowsError:
>    print(sys.exc_info())
> 
> Here is the output:
> 
> *** Python 2.5.4 (r254:67916, Dec 23 
> 2008, 15:10:54) [MSC v.1310 32 bit 
> (Intel)] on win32. ***
> >>> 
> Command Line : --Python25
> (<type 'exceptions.WindowsError'>, 
> WindowsError(2, 'The system cannot find 
> the file specified'), <traceback object 
> at 0x021864E0>)
> >>> 
> 
> The doc seems to indicate that the 
> command can be in "args", in this case 
> "executable" is unnecessary.
> 
> Am I misreading the doc?
> 

Not that I'm a Windows user, but your example doesn't appear to make any
sense to me.

According to the docs:

    args should be a string, or a sequence of program arguments.  The
    program to execute is normally the first item in the args sequence
or
    string, but can be explicitly set by using the executable argument.

There is no executable argument passed in your example, so the first
argument should point to an executable. 

'ftype py=C:\Python25\Python.exe' doesn't seem like an executable to me.

-a





More information about the Python-list mailing list