I would like to get the unix file type of a file specified by path (find out whether it is a regular file, a named pipe, a block device, ...)
I found in the docs os.stat(path).st_type but in python 3.6, this seems not to work.
Another approach is to use os.DirEntry objects (e. g. by os.listdir(path) ), but there are only methods is_dir() , is_file() and is_symlink() .
Any ideas how to do it?
Python 3.6 has pathlib and its Path objects have methods:
is_dir() is_file() is_symlink() is_socket() is_fifo() is_block_device() is_char_device()pathlib takes a bit to get used to (at least for me having come to Python from C/C++ on Unix), but it is a nice library