How to catch a line with Popen

Chris Rebert clp2 at rebertia.com
Sun May 29 06:26:49 EDT 2011


On Sun, May 29, 2011 at 3:02 AM, TheSaint <nobody at nowhere.net.no> wrote:
> Tim Roberts wrote:
>
>> Are you specifying a buffer size in the Popen command?  If not, then the
>> Python side of things is unbuffered
>
> The buffer is as per default. The program reports one line around 1/2 second
> time.
> I think I'll look into the option as Nobody states:
>
>        p = subprocess.Popen(...)
>        for line in p.stdout:
>            ...
>        p.wait()
>
> It is strange that would take a for cycle, rather than catching the line on-
> the-fly. I can judge it now, I'm going to try it out.

What do you mean by "on-the-fly" in this context?

Cheers,
Chris



More information about the Python-list mailing list