Python os.chflags() Method


Description

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.

Syntax

Following is the syntax for chflags() method −

os.chflags(path, flags)

Parameters

Return Value

This method does not return any value.

Example

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

#!/usr/bin/python
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
python_files_io.htm