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.

53

54

55

56

57

58

59

60

61

62

os.symlink(src, dst)

Create a symbolic link pointing to src named dst.

os.tcgetpgrp(fd)

Return the process group associated with the terminal given by fd (an open file descriptor as

returned by open()).

os.tcsetpgrp(fd, pg)

Set the process group associated with the terminal given by fd (an open file descriptor as returned

by open()) to pg.

os.tempnam([dir[, prefix]])

Return a unique path name that is reasonable for creating a temporary file.

os.tmpfile()

Return a new file object opened in update mode (w+b).

os.tmpnam()

Return a unique path name that is reasonable for creating a temporary file.

os.ttyname(fd)

Return a string which specifies the terminal device associated with file descriptor fd. If fd is not

associated with a terminal device, an exception is raised.

os.unlink(path)

Remove the file path.

os.utime(path, times)

Set the access and modified times of the file specified by path.

os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])

Generate the file names in a directory tree by walking the tree either top-down or bottom-up.

63

os.write(fd, str)

Write the string str to file descriptor fd. Return the number of bytes actually written.

os.access(path, mode)

Description

The method access() uses the real uid/gid to test for access to path. Most operations will use the effective

uid/gid, therefore this routine can be used in a suid/sgid environment to test if the invoking user has the specified

access to path.It returns True if access is allowed, False if not.

Syntax

Following is the syntax for access() method:

os.access(path, mode);

Parameters

• path -- This is the path which would be tested for existence or any access.

• mode -- This should be F_OK to test the existence of path, or it can be the inclusive OR of one or more of

R_OK, W_OK, and X_OK to test permissions.

• os.F_OK: Value to pass as the mode parameter of access() to test the existence of path.

• os.R_OK: Value to include in the mode parameter of access() to test the readability of path.

• os.W_OK Value to include in the mode parameter of access() to test the writability of path.

TUTORIALS POINT

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!