title: Print out the output of os.popen() without buffering in python
body: <p>Let's say that I have a process that prints out some data something like this ruby code. </p>
  
  <pre><code>1.upto(10) { 
    |i| 
    puts i 
    puts "\n" 
    sleep 0.6 
  } 
  </code></pre>
  
  <p>I want to have a python code that spawns this process, and read data from it to print it out. </p>
  
  <pre><code>import os 
  import sys 
  cmd = "ruby /Users/smcho/Desktop/testit.rb"; 
  pingaling = os.popen(cmd,"r") 
  while 1: 
      line = pingaling.readline() 
      if not line: break 
      print line, 
      sys.stdout.flush() 
  pingaling.close() 
  </code></pre>
  
  <p>The problem of this code is that it doesn't print the number one by one. It seems like that python prints out all the buffered data at the last point. </p>
  
  <p>Is there a way to print out the output of spawned process without buffering?</p>