check if the given path is a directory, file, symbolic link, mount point etc.

Download python eBook

Example

to check if the given path is a directory

dirname = '/home/john/python'
os.path.isdir(dirname)

to check if the given path is a file

filename = dirname + 'main.py'
os.path.isfile(filename)

to check if the given path is symbolic link

symlink = dirname + 'some_sym_link'
os.path.islink(symlink)

to check if the given path is a mount point

mount_path = '/home'
os.path.ismount(mount_path)

Stats

Contributors: 1
2016-08-26
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook