title: How can I change the file permissions in Python?
body: <p>I am trying to find the equivalent <strong>Python</strong> code to this <strong>PHP</strong> code, but I'm not sure how to translate the <code>0640</code>:</p>
  
  <p><strong>PHP</strong> code:</p>
  
  <pre><code>chmod($credentials_file, 0640);
  chown($credentials_file, 'webapp');
  </code></pre>
  
  <p>I'm looking at the os.chmod documentation <a href="https://docs.python.org/2/library/os.html#os.chmod" rel="nofollow">here</a>, but I'm not sure how <code>0640</code> equates to <code>stat.SOMETHING_HERE</code>. Does anyone have any idea how to port these two lines to <strong>Python</strong>?</p>