Python os.chflags() Method


The method chflags() sets the flags of path to the numeric flags. The flags may take a combination (bitwise OR) of the various values described below.

Note − This method is available Python version 2.6 onwards. Most of the flags can be changed by super-user only.


Following is the syntax for chflags() method −

os.chflags(path, flags)


Return Value

This method does not return any value.


The following example shows the usage of chflags() method.

import os
import stat

path = "/tmp/foo.txt"

# Set a flag so that file may not be renamed or deleted.
flags = os.SF_NOUNLINK
retval = os.chflags( path, flags)
print "Return Value: %s" % retval

When we run above program, it produces following result −

Return Value : None