title: Using python Popen to read the last line
body: <p>I have a simple python program:</p>
  
  <p>test.py:</p>
  
  <pre><code>import time
  for i in range(100000):
      print i
      time.sleep(0.5)
  </code></pre>
  
  <p>I want to use another program that executes the above one in order to read the last line output while the above program is counting.</p>
  
  <pre><code>import subprocess
  
  process = subprocess.Popen("test",stdout=PIPE)
  sleep(20) # sleeps an arbitrary time
  print stdout.readlines()[-1]
  </code></pre>
  
  <p>The problem is that <code>process.stdout.readlines()</code> waits until test.py finishes execution. 
  Is there any way to read the last line that has been writen in the output while the program is executing?</p>