title: Subprocess module fails to run command
body: <p>I'm trying to execute Google's cpplint.py on a group of my files and collect the results to one log file. However, I have not managed to beat the subprocess module. My current code is here:</p>
  
  <pre><code>import os, subprocess
  
  rootdir = "C:/users/me/Documents/dev/"
  srcdir = "project/src/"
  
  with open(rootdir+srcdir+"log.txt", mode='w', encoding='utf-8') as logfile:
      for subdir, dirs, files in os.walk(rootdir+srcdir):
          for file in files:
              if file.endswith(".h") or file.endswith(".cpp"):
                  filewithpath=os.path.join(subdir, file)
                  cmd=['c:/Python27/python.exe','C:/users/me/Documents/dev/cpplint.py','--filter=-whitespace,-legal,-build/include,-build/header_guard/', filewithpath]               
                  output = subprocess.check_output(cmd)
                  logfile.write(output.decode('ascii'))
  </code></pre>
  
  <p>Trying to run the above code throws an error:</p>
  
  <pre><code>  File "C:\Python32\lib\site.py", line 159
      file=sys.stderr)
          ^ SyntaxError: invalid syntax Traceback (most recent call last):   File "C:\Users\me\Documents\dev\project\src\verifier.py", line 19, in &lt;module&gt;
      output = subprocess.check_output(cmd)   File "C:\Python32\lib\subprocess.py", line 511, in check_output
      raise CalledProcessError(retcode, cmd, output=output) subprocess.CalledProcessError: Command '['c:/Python27/python.exe', 'C:/users/me/Documents/dev/cpplint.py', '--filter=-whitespace,-legal,-build/include,-build/header_guard/', 'C:/users/me/Documents/dev/project/src/aboutdialog.cpp']' returned non-zero exit status 1
  </code></pre>
  
  <p>If I substitute the cmd with something simpler like:</p>
  
  <pre><code>cmd=['C:/WinAVR-20100110/bin/avr-gcc.exe','--version']
  </code></pre>
  
  <p>Then the script works as expected.</p>
  
  <p>I have also tried to use a single command string instead of a list of strings as cmd, but the result is the same.
  When debugging the code, I copied the list-of-strings-turned-into-the-command-line-command from the debugger and ran it in the Windows command line, and the command ran as expected.</p>
  
  <p>The Python interpreter running my script is Python 3.2.
  Any tips are greatly appreciated.</p>