starting windows program from python based on file extension ?
Tim Golden
tim.golden at viacom-outdoor.co.uk
Thu Mar 3 06:02:42 EST 2005
[kowald at molgen.mpg.de]
| I used python to build a HTML file and now I would like to
| automatically start my browser to display this file. I guess I could
| use os.system(), but then I had to specify a specific path to the
| browser.
|
| I wonder if it is possible to tell windows to open "myFile.html" using
| the program that is registered to open html files (similar to double
| clicking on the file).
|
| Any idea how to do that from python ??
Python 2.3.5c1 (#61, Jan 25 2005, 19:52:06) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.startfile
<built-in function startfile>
>>> help (os.startfile)
Help on built-in function startfile:
startfile(...)
startfile(filepath) - Start a file with its associated application.
This acts like double-clicking the file in Explorer, or giving the file
name as an argument to the DOS "start" command: the file is opened
with whatever application (if any) its extension is associated.
startfile returns as soon as the associated application is launched.
There is no option to wait for the application to close, and no way
to retrieve the application's exit status.
The filepath is relative to the current directory. If you want to use
an absolute path, make sure the first character is not a slash ("/");
the underlying Win32 ShellExecute function doesn't work if it is.
>>>
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Python-list
mailing list