os.system

Alex Martelli alex at magenta.com
Fri Jul 7 04:52:17 EDT 2000


pehr anderson <pehr at pehr.net> wrote in message
news:39653D15.E4DE6131 at pehr.net...
> Dear Matthias,
>
> In general, calling os.system causes the system to start a shell
> which then processes the command string.
    [snip]
> All I can offer is an explanation, not a speedup.
> Perhaps you could find a way to talk to a browser that
> may already be started?

Not all that difficult:

>>> import win32api
>>> win32api.ShellExecute(0,"open","c:\\pippo.htm",None,"",0)
33
>>>

This opens the given URL, in an existing and suitable browser
window if possible, else in a newly generated one, and I find
it to be very fast.  (The returned "33" doesn't mean much of
anything -- just check that it's not 32 or less, those would
be errors -- just the N+1-th annoying Win32 API quirk:-).


> I'd recommend browsing "Python for Win32" if you are serious
> about surviving under windows.

Yes, and I'm not even sure that would suffice (is ShellExecute
documented there?  I'm familiar with it, because I routinely
program under Win32 with other languages, so that's the first
thing I looked for when trying to do something equivalent to
a "start" from commandline, but I'm not sure how a Win32 newbie
would learn about it...).

Hammond's book is excellent, and so are his win32* extensions,
but there might still be lots of difficulty for programmers
that are not familiar at all with Win32 and its API's.


Alex






More information about the Python-list mailing list