os.popen() vs os.system()

charliehubbard at my-deja.com charliehubbard at my-deja.com
Wed Dec 22 10:47:43 EST 1999


In article <Pine.WNT.4.21.9912220944130.205-100000 at wks_3.e-
shopwork.com>,
  NULL at my.pc wrote:
> Newbie...
>
> From what I've deciphered, the only differences between os.popen() and
> os.system() are:
>
> a) popen automatically starts a new process while system only does it
> if you include an &
>
> b) popen hooks onto stdout and stdin
>
> ??? If so, what's the use of os.system()?

os.system is a standard call to the C standard function call system().
It doesn't allow you to catch the output of the program like os.popen
does.  os.popen is piped open so that you can capture in your python
scripts what the program outputs.  os.system simply calls the outside
program and sends it's contents to stdout which can be redirected to
a file in your shell.  Call os.system if your python program doesn't
need to capture anything from your outside program.

charlie


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list