os.system

Alex Martelli alex at magenta.com
Fri Jul 7 11:42:35 EDT 2000


Matthias Huening <matthias.huening at univie.ac.at> wrote in message
news:8k4rep$28j8$1 at www.univie.ac.at...
>
> Alex Martelli :
>
> > Not all that difficult:
> >
> > >>> import win32api
> > >>> win32api.ShellExecute(0,"open","c:\\pippo.htm",None,"",0)
>
> Thanks! That's exactly what I was looking for.

Always glad to be of help.

> I had found another solution on this group:
>
> > import win32com.client
> > ie=win32com.client.Dispatch('InternetExplorer.Application.1')
> > ie.Visible=1
> > ie.Navigate("http://www.python.org/")
>
> Disadvantage: this only works for one browser (in this case IE).

Advantage: you can do a *LOT* of beautiful things to an
application that you've started via Automation, as well
as making it visible/invisible, and asking it to navigate
somewhere; with ShellExecute or similar methods you just
don't get that much power and flexibility.

I remember seeing on the net a COM/Automation "decorator"
for Netscape Navigator (I forget which exact version of Navigator
it needed), implementing exactly the InternerExplorer.Application
interface of IE, to allow interchangeability (alas, only to
"skin-deep": Navigator just can't expose the HTML Document
Object Model in a W3C-compliant way, the way IE can, sigh).


> > > 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.
>
> That's exactly my problem. I am not much of a programmer, but sometimes I
> need a script to get things done and that is what I use Python for. I
think
> Python is a good all purpose language for the CP4E-kind-of-people like me
> (I tried Perl before...). But the Win API's remain mysterious for me, at
> least till now.

Hammond's book will help!  But maybe there's a niche for a Win32-novice-
friendly way to approach some common Win32 tasks, in a Python package
written on top of Hammond's splendid modules; e.g., a "start" function
exactly mimicking the commandline "start" verb of Win32, which is easy
to build on top of win32api.ShellExecute but might be more intuitive.


Akex






More information about the Python-list mailing list