Write a Python program to find the path to a file or directory when you encounter a path name.
1 2 3 4 5 6 7 8 9 10 11 |
import os.path for file in [ __file__, os.path.dirname(__file__), '/', './broken_link']: print('File :', file) print('Absolute :', os.path.isabs(file)) print('Is File? :', os.path.isfile(file)) print('Is Dir? :', os.path.isdir(file)) print('Is Link? :', os.path.islink(file)) print('Exists? :', os.path.exists(file)) print('Link Exists?:', os.path.lexists(file)) |