[Tutor] Running external commands from Python
Randy Kao
randykao at gmail.com
Sat Jun 26 00:46:17 CEST 2010
Hi all,
I'm a newbie to Python (switching from Perl) and had a question about the
best way to run external commands in Python.
In doing some reading I'm confused about which is the best way to accomplish
this.
With Perl, the way I went about running commands was by opening a filehandle
and parsing / manipulating the data.
i.e. open(XYZ, "ls -la *");
In trying to do this in Python, I think I've read a couple ways to do this.
through: os.popen, os.popen2, os.popen3, os.system, commands.getoutput()
I might not be understanding when to use which of these correctly and was
hoping for some feedback from this more experienced group.
Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100625/8ef51074/attachment.html>
More information about the Tutor
mailing list