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

suggest change

to check if the given path is a directory

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

The file and link snippets below use import os and dirname from the first snippet.

to check if the given path is a file

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

to check if the given path is symbolic link

symlink = os.path.join(dirname, 'some_sym_link')
os.path.islink(symlink)

to check if the given path is a mount point

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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents