"vince spicer" <vinces1...@gmail.com> wrote
import commands
output = commands.getout("ls -lah")

There are many ways to do this in Python including os.popen, commands and subprocess.

But subprocess is the "officially correct" version, the others are deprecated and could theoretically disappear in a future version of Python. (But not soon I suspect because of the amount of legacy code that uses it!)

But its definitely worth weaning oneself onto subprocess even though it is initially harder work. In the end the superior flexibility and consistency of approach pay back.

Alan G.


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

Reply via email to