stat

The stat module defines constants and functions for interpreting the results of os.stat(), os.fstat(), and os.lstat(). These functions return a 10-tuple containing file information. The following variables define the indices within the tuple for certain items and are listed in the order in which they commonly appear in the tuple:

VariableDescription
ST_MODEInode protection mode
ST_INOInode number
ST_DEVDevice the inode resides on
ST_NLINKNumber of links to the inode
ST_UIDUser ID of the owner
ST_GIDGroup ID of the owner
ST_SIZEFile size in bytes
ST_ATIMETime of last access
ST_MTIMETime of last modification
ST_CTIMETime of last status change

The following functions can be used to test file properties given the mode value returned using os.stat(path)[stat.ST_MODE] ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.