28.10.2021 Views

Python Tutorial ( PDFDrive )

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

# Close opened file

os.close( fd )

Let us compile and run the above program, this will produce the following result:

Returned value is: False

os.lchflags(path, flags)

Description

The method lchflags() sets the flags of path to the numeric flags. This method does not follow symbolic links

unlike chflags() method.

Here, flags may take a combination (bitwise OR) of the following values (as defined in the stat module):

• UF_NODUMP: Do not dump the file.

• UF_IMMUTABLE: The file may not be changed.

• UF_APPEND: The file may only be appended to.

• UF_NOUNLINK: The file may not be renamed or deleted.

• UF_OPAQUE: The directory is opaque when viewed through a union stack.

• SF_ARCHIVED: The file may be archived.

• SF_IMMUTABLE: The file may not be changed.

• SF_APPEND: The file may only be appended to.

• SF_NOUNLINK: The file may not be renamed or deleted.

• SF_SNAPSHOT: The file is a snapshot file.

Note: This method has been introduced in Python 2.6

Syntax

Following is the syntax for lchflags() method:

os.lchflags(path, flags)

Parameters

• path -- This is the file path for which flags to be set.

• flags -- This could be a combination (bitwise OR) of the above defined flags values.

Return Value

This method does not return any value.

Example

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

#!/usr/bin/python

import os, sys

# Open a file

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!