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.

Return Value

This method does not return any value.

Example

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

#!/usr/bin/python

import os

path = "/usr/tmp"

# Check current working directory.

retval = os.getcwd()

print "Current working directory %s" % retval

# Now change the directory

os.chdir( path )

# Check current working directory.

retval = os.getcwd()

print "Directory changed successfully %s" % retval

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

Current working directory /usr

Directory changed successfully /usr/tmp

os.chflags(path, flags)

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

• path -- This is complete path of the directory to be changed to a new location.

TUTORIALS POINT

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!