Possible Duplicate:
read subprocess stdout line by line
I wrote a C++ program that generates all bunch of text in the Linux console.
I am using a python script to parse the output of this C++. I am doing this like that:
cmd = ["./starter"]
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE)
for line in p.stdout:
strLine = str(line).rstrip()
print(">>> " + strLine )
This is working. BUT i have a major problem, the output is not live. I mean by that, that after starting the script nothing is printed out, but only after couple second things are coming out.. It is almost like python is waiting a number of character max to then print them all at once...
Is there a way to tell python to print a line AS SOON AS it was printed by the C++ program ?