Python os.fstat() Method
Example
Get status of a file:
# Import os Library
import os
# Open file
fd = os.open("test.txt", os.O_RDONLY)
# Get status of the file
print (os.fstat(fd))
# Close file
os.close(fd)
Run Code »
Definition and Usage
The os.fstat()
method returns the status of a file,
as a stat_result
object.
Tip: This method is equal to os.stat(fd)
.
Note: Available on both WINDOWS and UNIX platforms.
Syntax
os.fstat(fd)
Parameter Values
Parameter | Description |
---|---|
fd | Required. Represents a file descriptor |
Technical Details
Return Value: | A stat_result object, representing the
status of the file descriptor:st_mode - The file type and file mode bitsst_ino - The inode number (Unix) or file index (Windows)st_dev - The id of the device where the file residesst_nlink - The number of hard linksst_uid - The user id of file ownerst_gid - The group id of file ownerst_rdev - The type of devicest_size - The size of file, in bytesst_blksize - The blocksize for filesystem I/Ost_blocks - The number of 512-byte blocks allocatedst_atime - The time of last accessst_mtime - The time of last content modificationst_ctime - The time of last metadata change |
---|---|
Python Version: | 2.6 |
Change Log: | 3.3: This is equivalent to os.stat(fd) |