O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required