Change the mode of path to the numeric mode. mode is a four-digit number representing the description of the the permissions of path. The numerical value represents the permissions-level. The position in the four-digit number represents who has these permissions. The numerical value is one of:
1 -- execute permission
2 -- read permission
4 -- write permission
6 -- read & write permission (read (2) + write (4))
7 -- read, write & execute permission (read (2) + write (4) + execute (1))
The first digit is always "0". The second digit represents the rights the user has. The third digit represents the rights the group has. The fourth digit represents the rights others have.
For example, if everyone should have read, write, and execute privilages to the file, then mode should be set to 0777.
Example:
import os
os.chmod('myfile.txt', 0666) # Lets everyone have read & write permissions to 'myfile.txt'
Note for Windows users: The four-digit value works on Windows as well. However, you will see a different numerical value returned when using os.stat and stat.
Example
>>> import os, stat
>>> os.chmod('myfile.txt', 0666)
>>> file_info = os.stat('myfile.txt')
>>> print file_info[stat.ST_MODE]
33206
Availability: Unix, Windows.