If you plan on using those files then neither. Files may be deleted or permissions changed between your call and when you use the file, making that information obsolete. Instead just try to use the file and handle the exception there:
try:
with open(fname, 'r') as f:
# use f
except FileNotFoundError as e:
# file was deleted
except IsADirectoryError as e:
# path exists but is a directory
except PermissionError as e:
# you don't have permissions to read the file
except OSError as e:
# other error
If however you are writing a tool that is displaying the information about permissions to the user, then it makes sense to use the methods and functions provided for specifically this purpose, hence you should use os.path.exists
and os.is_file
and os.is_dir
.
If you are dealing with entire directories note that it is more efficient to use os.scandir
and check the methods on the DirEntry
s objects.