title: Python subprocess with complex arguments
body: <p>I'm looking for the safest and most convenient way to call a shell command from python(3). Here a ps to pdf conversion:</p>
  
  <pre><code> gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile="${pdf_file}" "${ps_file}"
  </code></pre>
  
  <p>I use <code>subprocess</code>, <code>shlex</code> and avoid <code>shell=True</code>.
  But I find the resulting command inconsistent:</p>
  
  <pre><code>cmd = ['gs', '-dBATCH', '-dNOPAUSE', '-sDEVICE=pdfwrite', '-sOutputFile={0}'.format(pdf_filename), ps_filename]
  </code></pre>
  
  <p>What do I miss?! <code>subprocess.call()</code> syntax looks so clean with space separated arguments, and looks such a mess everywhere else.</p>
  
  <p>What's the difference when calling <code>subprocess.call(cmd)</code> (at python level, ie. escaping, injection protection, quoting, etc.) between:</p>
  
  <pre><code>cmd = ['do', '--something', arg]
  cmd = ['do', '--someting {0}'.format(arg)]
  </code></pre>
  
  <p>If none, is this, also, a good way to do it ?</p>
  
  <pre><code>cmd = ['gs', '-dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile={0} {1}'.format(pdf_filename, ps_filename)]
  </code></pre>
  
  <p>Another example of inconsistency:</p>
  
  <p><code>hg merge -r 3</code> would be <code>cmd = ['hg', 'merge', '-r', revision_id]</code></p>
  
  <p><code>hg merge --rev=3</code> would be <code>cmd = ['hg', 'merge', '--rev={0}'.format(revision_id)]</code></p>
  
  <p>despite the fact, it is two ways to send the same arguments.</p>