The stat module contains a number of variables
used in encoding and decoding various items returned by
certain methods in the os module, such as stat() and chmod().
First, there are constants for indexing the
components of a “status tuple” such as that returned by
os.stat():
ST_ATIME |
The epoch time of last access (see the time
module for interpretation of times).
|
ST_CTIME | The epoch time of the file's last status change. |
ST_DEV | The device number. |
ST_GID | The group ID. |
ST_INO | The i-node number. |
ST_MODE | The file's permissions. |
ST_MTIME | The epoch time of last modification. |
ST_NLINK | The number of hard links. |
ST_SIZE | The current size in bytes. |
ST_UID | The user ID. |
The following functions are defined in the
stat module for testing a mode
value ,
where m
is the mST_MODE element of the
status tuple. Each function is a predicate:
S_ISBLK(
| Is this a block device? |
S_ISCHR(
| Is this a character device? |
S_ISDIR(
| Is this a directory? |
S_ISFIFO(
| Is this a FIFO? |
S_ISLNK(
| Is this a soft (symbolic) link? |
S_ISREG(
| Is this an ordinary file? |
S_ISSOCK(
| Is this a socket? |
These constants are defined for use as mask values in testing
and assembling permission values such as those returned by
os.stat() in Section 28.7, “os: The operating
system interface”.
S_IRGRP | Group read permission. |
S_IROTH | World read permission. |
S_IRUSR | Owner read permission. |
S_ISGID | SGID (set group ID) bit. |
S_ISUID | SUID (set user ID) bit. |
S_IWGRP | Group write permission. |
S_IWOTH | World write permission. |
S_IWUSR | Owner write permission. |
S_IXGRP | Group execute permission. |
S_IXOTH | World execute permission. |
S_IXUSR | Owner execute permission. |