all Python 3statfunction
stat.S_ISFIFO()
file type
Checks from st_mode that the object is a pipe: a named FIFO or an anonymous one from os.pipe().
Syntax
stat.S_ISFIFO(os.fstat(fd).st_mode)
It answers "was I given another program's output as input?": with `cmd | python x.py`, S_ISFIFO(os.fstat(0).st_mode) is true. A pipe cannot be rewound: seek() and re-reading fail, and reads block until the writer closes, so code written for regular files hangs or crashes on a pipe.
Examples
import os, stat
r, w = os.pipe()
print(stat.S_ISFIFO(os.fstat(r).st_mode)) # → True
os.close(r)
os.close(w)
See also
Open in the full glossarydocs.python.orgReport an inaccuracy