line-by-line output from a subproce

Michael Chermside mcherm at mcherm.com
Tue May 24 12:46:10 EDT 2005


I wrote:
> I am using the subprocess module to invoke a command-line utility
> [...] I would like to process the output line-by-line [...]
> rather than running [...] to completion

Simon Percivall writes:
> Okay, so the reason what you're trying to do doesn't work is that the
> readahead buffer used by the file iterator is 8192 bytes, which clearly
> might be too much.

Jp Calderone writes:
>     def iterread(fobj):
>         return iter(fobj.readline, '')

Thanks folks... that did it nicely!

-- Michael Chermside




More information about the Python-list mailing list