Python os.path.ismount() Method Example
Below, we are explaing the example of Python mount, those are following.
On Linux system, the partitions and their mount points information can be displayed using the df command.
For example:
Check if Paths are Mount Points using Python Mount (On Unix)
In this example , below Python code uses the os.path
module to check if “/run” and “/dev” are mount points. It determines whether each path corresponds to a mounted file system and check for the “/dev” path.
Python3
# importing os.path module import os.path # Path path = "/run" # Check whether the # given path is a # mount point or not ismount = os.path.ismount(path) # Path path = "/dev" # Check whether the # given path is a # mount point or not ismount = os.path.ismount(path) print (ismount) |
True True
Check if Paths are Mount Points using Python Mount (On Windows)
In this example, Python code uses the os.path module to check if “C:” is a mount point on Windows. It determines whether the specified path corresponds to a drive letter root, and indicating whether “C:” is a mount point or not.
Python3
# importing os.path module import os.path # On Windows, a drive letter root # and a share UNC are always # mount points Path path = "C:" # Check whether the # given path is a # mount point or not ismount = os.path.ismount(path) print (ismount) |
True
Python | os.path.ismount() method
os.path module is sub module of Python OS Module in Python used for common path name manipulation.
os.path.ismount()
method in Python is used to check whether the given path is a mount point or not. A mount point is a point in a file system where a different file system has been mounted.