2009/2/4 Helmut Jarausch <jarau...@skynet.be>: > using e.g. > import subprocess > Package='app-arch/lzma-utils' > EQ=subprocess.Popen(['/usr/bin/equery','depends',Package],stdout=subprocess.PIPE) > EQ_output= EQ.communicate()[0] > EQ_output is a string containing multiple lines. > I'd prefer a file-like object, e.g. EQ_OUT > so that I can loop over the lines of it like
EQ.stdout is the filelike object you're looking for. communicate() grabs entire output at once so don't use it. import subprocess Package = 'app-arch/lzma-utils' EQ = subprocess.Popen(['/usr/bin/equery', 'depends', Package], stdout=subprocess.PIPE) for line in EQ.stdout: do_stuff_with(line) -- http://mail.python.org/mailman/listinfo/python-list