launching a file with its associated application on windows

Alan Miller ajm at enteract.com
Fri Jun 22 18:48:52 EDT 2001


Volucris (volucris at hotmail.com) wrote:
>"Volucris" <volucris at hotmail.com> wrote in message
>news:3b313ae6$0$327$6e49188b at news.goldengate.net...
>> If it's pre 2.0, I think you can prefix a popen() command with 'start ' to
>> do the same thing.
>>
>> import os
>> os.popen('start %s' % r'C:\sish\MyPic.bmp')
>
>yeah, I'm stupid. That should be system() not popen(), although popen()
>would work, too, depending on what exactly you are doing. You wouldn't want
>a pipe to a (.bmp) file, though, would you? Maybe. I don't know. I'm
>rambling again. Good bye.

Actually, I don't believe using popen() would cause any problems - 
you're unlikely to get anything useful back from it, but "start" is 
actually a command in its own right that does the lookup and starts the 
appropriate program.  Unless it's started with /WAIT, it should exit 
immediately after launching the the program associated with the input 
file.

ajm



More information about the Python-list mailing list