Python os.fstat() Method


Description

Python method fstat() returns information about a file associated with the fd. Here is the structure returned by fstat method −

Syntax

Following is the syntax for fstat() method −

os.fstat(fd)

Parameters

Return Value

This method returns information about a file associated with the fd.

Example

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

#!/usr/bin/python

import os, sys

# Open a file
fd = os.open( "foo.txt", os.O_RDWR|os.O_CREAT )

# Now get  the touple
info = os.fstat(fd)

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

# Close opened file
os.close( fd)

When we run above program, it produces following result −

File Info : (33261, 3753776L, 103L, 1, 0, 0, 
            102L, 1238783197, 1238786767, 1238786767)
UID of the file :0
GID of the file :0
python_files_io.htm