[Tutor] calling an external program

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Feb 14 19:05:42 CET 2005



On Mon, 14 Feb 2005, Alan Gauld wrote:

> > - I am trying to call up an external program with something like a
> > "Shell" command - can not find a way of doing this (in windows)
>
> Look in the os module, there are several options depending on exactly
> what you need to do. The simplest option is system(). To read the output
> look at the various popen() and for more sophisticated options try the
> exec() family.
>
> If using system() on DOS you might look at the START DOS command too for
> the options available there.

Hi Alan and Lobster,

I hope the plethora of choices isn't overwhelming!  *grin*

As of Python 2.4, there is a nicer external process caller in the new
'subprocess' module:

    http://www.python.org/doc/lib/module-subprocess.html

It tries to consolidate the major functionality of the other methods.  I
haven't played with it much, but according to the documentation, it looks
very capable.

Best of wishes to you!



More information about the Tutor mailing list