How to catch a line with Popen

TheSaint nobody at nowhere.net.no
Sun May 29 09:52:22 EDT 2011


Chris Rebert wrote:

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

I just suppose to elaborate the latest line, as soon it's written on the 
pipe, and print some result on the screen.
Imaging something like

 p= Popen(['ping','-c40','www.google.com'], stdout=PIPE)
 for line in p.stdout:
     print(str(line).split()[7])

I'd like to see something like *time=54.4*
This is just an example, where if we remove the "-c40" on the command line, 
I'd expect to read the latest line(s), until the program will be killed.

-- 
goto /dev/null



More information about the Python-list mailing list