title: Popen with Context Managers
body: <p>I have been trying to write a function which would execute a command passed to it thru a parameter using <code>POPEN</code> along with Context Managers. Unfortunately, I am unable to get it to work. Can someone please help?</p>
  
  <pre><code>import os
  import sys
  import subprocess
  import inspect    
  
  def run_process(cmd_args):
      with subprocess.Popen(cmd_args, stdout=subprocess.PIPE) as proc:
          log.write(proc.stdout.read())
  
  run_process("print('Hello')")
  </code></pre>
  
  <p>The output expected is <code>"Hello"</code>. Can someone please point out where I am going wrong?</p>