title: Python subprocess Popen: Why does "ls *.txt" not work?
body: <p>I was looking at <a href="https://stackoverflow.com/questions/4760215/running-shell-command-from-python-and-capturing-the-output">this</a> question.</p>
  
  <p>In my case, I want to do a :</p>
  
  <pre><code>import subprocess
  p = subprocess.Popen(['ls', 'folder/*.txt'], stdout=subprocess.PIPE, 
                                   stderr=subprocess.PIPE)
  
  out, err = p.communicate()
  </code></pre>
  
  <p>Now I can check on the commandline that doing a  "ls folder/*.txt" works, as the folder has many .txt files.</p>
  
  <p>But in Python (2.6) I get:</p>
  
  <p><em>ls: cannot access * : No such file or directory</em></p>
  
  <p>I have tried doing:
  <code>r'folder/\*.txt'</code>
  <code>r"folder/\*.txt"</code>
  <code>r'folder/\\*.txt'</code>
  and other variations, but it seems <code>Popen</code> does not like the <code>*</code> character at all.</p>
  
  <p>Is there any other way to escape <code>*</code>?</p>