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 )

# Now get the touple

info = os.lstat(path)

print "File Info :", info

# Now get uid of the file

print "UID of the file :%d" % info.st_uid

# Now get gid of the file

print "GID of the file :%d" % info.st_gid

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

File Info : (33261, 3450178L, 103L, 1, 500, 500, 0L,

1238866944, 1238866944, 1238948312)

UID of the file :500

GID of the file :500

os.major(device)

Description

The method major() extracts the device major number from a raw device number (usually the st_dev or st_rdev

field from stat).

Syntax

Following is the syntax for major() method:

os.major(device)

Parameters

• device -- This is a raw device number (usually the st_dev or st_rdev field from stat).

Return Value

This method returns the device major number.

Example

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

#!/usr/bin/python

import os, sys

path = "/var/www/html/foo.txt"

TUTORIALS POINT

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!