Python Glossary Русский

all Python 3osfunction

os.path.ismount

os.path — existence and type checks

Check whether a path is a filesystem mount point.

Syntax

os.path.ismount(path)

On POSIX the check compares the device and inode with the parent directory, so a bind mount within the same filesystem may go unnoticed, while a btrfs subvolume on Linux always counts as a mount point. On Windows a drive root and a UNC share are always mount points.

Examples

import os
print(os.path.ismount('some_file.txt'))   # → False
print(os.path.ismount('/'))   # → True
print(os.path.ismount(os.path.dirname(os.__file__)))   # → False
p = os.path.abspath(os.__file__)   # ищем файловую систему, в которой лежит файл
while not os.path.ismount(p): p = os.path.dirname(p)
print(os.path.ismount(p))   # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy