title: How do you do a simple "chmod +x" from within python?
body: <p>I want to create a file from within a python script that is executable.</p>
  
  <pre><code>import os
  import stat
  os.chmod('somefile', stat.S_IEXEC)
  </code></pre>
  
  <p>it appears <code>os.chmod</code> doesn't 'add' permissions the way unix <code>chmod</code> does. With the last line commented out, the file has the filemode <code>-rw-r--r--</code>, with it not commented out, the file mode is <code>---x------</code>. How can I just add the <code>u+x</code> flag while keeping the rest of the modes intact?</p>