title: Output of subprocess both to PIPE and directly to stdout
body: <p>I found a number of questions which looks like mine, but which did not produce a solution I can use (closest is: <a href="https://stackoverflow.com/questions/9859446/subprocess-output-to-stdout-and-to-pipe">subprocess output to stdout and to PIPE</a>)</p>
  
  <p>The problem: I want to start a process using subprocess which takes a long time. After running the command I need to parse the stdout-output and the stderr-output.</p>
  
  <p>Currently I do it as follows:</p>
  
  <pre><code>p = subprocess.Popen( command_list, stdout=subprocess.PIPE, 
      stderr=subprocess.PIPE )
  out, error_msg = p.communicate()
  print out + "\n\n" + error_msg
  
  #next comes code in which I check out and error_msg
  </code></pre>
  
  <p>But the drawback of this method is that the user does not see the output of the process while it is running. Only at the end the output is printed.</p>
  
  <p>Is there a way that the output is printed while the command is running (as if I gave the command without stdout/stderr=subprocess.PIPE) and still have the output via p.communicate in the end?</p>
  
  <p>Note: I'm currently developing on python 2.5 (old software release which uses this python version).</p>