Easy Tutorial
❮ Python String Lstrip Ref Math Degrees ❯

Python3 os.chflags() Method

Python3 OS File/Directory Methods


Overview

The os.chflags() method is used to set the flags of a path to numeric flags. Multiple flags can be combined using OR.

This method is only supported on Unix.

Syntax

The syntax for the chflags() method is as follows:

os.chflags(path, flags)

Parameters

Return Value

This method does not return a value.

Example

The following example demonstrates the use of the chflags() method:

#!/usr/bin/python3

import os, stat

path = "/tmp/foo.txt"

# Set flags for the file to prevent it from being renamed or deleted
flags = stat.SF_NOUNLINK
retval = os.chflags(path, flags)
print("Return Value: %s" % retval)

Executing the above program outputs:

Return Value: None

Python3 OS File/Directory Methods

❮ Python String Lstrip Ref Math Degrees ❯