title: subprocess.Popen.stdout - reading stdout in real-time (again)
body: <p>Again, the same question.<br>
  The reason is - I still can't make it work after reading the following:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1085071/">Real-time intercepting of stdout from another process in Python</a>  </li>
  <li><a href="https://stackoverflow.com/questions/527197/">Intercepting stdout of a subprocess while it is running</a>  </li>
  <li><a href="https://stackoverflow.com/questions/874815/">How do I get &#39;real-time&#39; information back from a subprocess.Popen in python (2.5)</a>  </li>
  <li><a href="https://stackoverflow.com/questions/1606795/">catching stdout in realtime from subprocess</a>  </li>
  </ul>
  
  <p>My case is that I have a console app written in C, lets take for example this code in a loop:</p>
  
  <pre><code>tmp = 0.0;   
  printf("\ninput&gt;&gt;"); 
  scanf_s("%f",&amp;tmp); 
  printf ("\ninput was: %f",tmp); 
  </code></pre>
  
  <p>It continuously reads some input and writes some output.</p>
  
  <p>My python code to interact with it is the following:</p>
  
  <pre><code>p=subprocess.Popen([path],stdout=subprocess.PIPE,stdin=subprocess.PIPE)
  p.stdin.write('12345\n')
  for line in p.stdout: 
      print("&gt;&gt;&gt; " + str(line.rstrip())) 
      p.stdout.flush() 
  </code></pre>
  
  <p>So far whenever I read form <code>p.stdout</code> it always waits until the process is terminated and then outputs an empty string. I've tried lots of stuff - but still the same result.</p>
  
  <p>I tried Python 2.6 and 3.1, but the version doesn't matter - I just need to make it work somewhere.</p>