Python method chmod() changes the mode of the path to the passed numeric mode. The mode may take one of the following values or bitwise ORed combinations of them −
Following is the syntax for chmod() method −
This method does not return any value.
The following example shows the usage of chmod() method
#!/usr/bin/python import os, sys, stat # Assuming /tmp/foo.txt exists, Set a file execute by the group. os.chmod("/tmp/foo.txt", stat.S_IXGRP) # Set a file write by others. os.chmod("/tmp/foo.txt", stat.S_IWOTH) print "Changed mode successfully!!"
When we run the above program, it produces the following result:
Changed mode successfully!!
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.