stat.S_IFMT()
stat.S_IFMT() is a Python function in the Stat Module category. Returns the file type field from the file mode. The syntax is stat.S_IFMT(mode). Returns: File type constant. A typical example: stat.S_IFMT(os.stat("file.txt").st_mode) # stat.S_IFREG. A close sibling is stat.S_ISDIR(), which returns True if the file mode indicates a directory. A close sibling is stat.S_ISREG(), which returns True if the file mode indicates a regular file. A close sibling is stat.S_ISLNK(), which returns True if the file mode indicates a symbolic link. A close sibling is stat.S_ISFIFO(), which returns True if the file mode indicates a FIFO (named pipe). More about this category: File stat constants — S_ISDIR, S_ISREG, S_IMODE, S_IFMT. Related Stat Module entries: stat.S_ISDIR(), stat.S_ISREG(), stat.S_ISLNK(), stat.S_ISFIFO(), stat.S_ISSOCK(), stat.S_IMODE(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.