How do I check if a file exists or not, without using the try statement?
You have the os.path.exists function:
import os.path os.path.exists(file_path)
This returns True for both files and directories but you can instead use
True
os.path.isfile(file_path)
to test if it's a file specifically. It follows symlinks.