from pathlib import Path my_file = Path("/path/to/file") if my_file.is_file(): # file exists if my_file.is_dir(): # directory exists if my_file.exists(): # path exists try: my_abs_path = my_file.resolve(strict=True) except FileNotFoundError: # doesn't exist else: # exists