"vince spicer" <vinces1...@gmail.com> wrote

Take a peak at commands.getoutput

Or more "correctly" look at the subprocess module.
All previous mechanisms for process control are rendered
obsolete and are deprecated in favour of subprocess

So if we aren't using popen lets at least use subprocess.

It is slightly more complex than popen or commands but
it is future proof (for now at least!)

Simple example:

import subprocess
lsout = subprocess.Popen('ls -ls', shell=True, stdout=subprocess.PIPE).stdout
print lsout.read()

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to