PyDocs

Nav

File and Directory Access

Path.exists

pathlib

method of Path (source)
  • Path.exists(*, follow_symlinks=True)
Whether this path exists.

This method normally follows symlinks; to check whether a symlink exists,
add the argument follow_symlinks=False.
Changed in 3.12
  • 3.12: The follow_symlinks parameter was added.
1 Example
>>> Path('').exists()  # The current directory.
True
>>> Path('.').exists()
True
>>> Path('setup.py').exists()
True
>>> Path('/etc').exists()
True
>>> Path('nonexistentfile').exists()
False
from the Python docs
See Also
No see-alsos for pathlib/Path.exists
0 Notes
No notes for Path.exists