title: Python module os.chmod(file, 664) does not change the permission to rw-rw-r-- but -w--wx----
body: <p>Recently I am using Python module os, when I tried to change the permission of a file, I did not get the expected result. For example, I intended to change the permission to rw-rw-r--,</p>
  
  <pre><code>os.chmod("/tmp/test_file", 664)
  </code></pre>
  
  <p>The ownership permission is actually -w--wx--- (230)</p>
  
  <pre><code>--w--wx--- 1 ag ag 0 Mar 25 05:45 test_file
  </code></pre>
  
  <p>However, if I change 664 to 0664 in the code, the result is just what I need, e.g.</p>
  
  <pre><code>os.chmod("/tmp/test_file", 0664)
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>-rw-rw-r-- 1 ag ag 0 Mar 25 05:55 test_file
  </code></pre>
  
  <p>Could anybody help explaining why does that leading 0 is so important to get the correct result?</p>