Python method fstat() returns information about a file associated with the fd. Here is the structure returned by fstat method:
Following is the syntax for fstat() method −
os.fstat(fd)
This method returns information about a file associated with the fd.
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 the above program, it produces the following result:
File Info : (33261, 3753776L, 103L, 1, 0, 0, 102L, 1238783197, 1238786767, 1238786767) UID of the file :0 GID of the file :0
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.