[Tutor] commands versus subprocess, I'm confused

Emad Nawfal (عماد نوفل) emadnawfal at gmail.com
Fri Dec 26 14:09:34 CET 2008


Hello Tutors, and Happy New Year and Holidays,
suppose I have an external program that prints "testing the subprocess
module"
I know I can run it through the commands module like this:

>>> a = commands.getoutput("python3.0 hello.py")
>>> a
'testing the subprocess module'
>>> len(a)
29
>>> b = a.split()
>>> b
['testing', 'the', 'subprocess', 'module']
>>> for word in b:
...     if word[-1] == 'e': print word
...
the
module
>>>

I cannot figure out how to do the same thing in the subprocess module. Can
somebody please explain how to get the same behaviour from, say,
subprocess.call

-- 
لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد
الغزالي
"No victim has ever been more repressed and alienated than the truth"

Emad Soliman Nawfal
Indiana University, Bloomington

--------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081226/5b32db6f/attachment.htm>


More information about the Tutor mailing list