title: Doing shell backquote in python?
body: <p>I am translating bash scripts into python for some reasons.</p>
  
  <p>Python is more powerfull, nevertheless, it is much more harder to code simple bash code like this :</p>
  
  <pre><code>MYVAR = `grep -c myfile`
  </code></pre>
  
  <p>With python I have first to define a backquote function could be : </p>
  
  <pre><code>def backquote(cmd,noErrorCode=(0,),output=PIPE,errout=PIPE):
      p=Popen(cmd, stdout=output, stderr=errout)
      comm=p.communicate()
      if p.returncode not in noErrorCode:
          raise OSError, comm[1]
      if comm[0]:
          return comm[0].rstrip().split('\n')
  </code></pre>
  
  <p>That is boring !</p>
  
  <p>Is there a Python's flavor (IPython ?) where it is easy to spawn process and get back the output ?</p>