Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add docstring; fix the doctest error in the documentation
  • Loading branch information
akulakov committed Nov 20, 2021
commit 9107f3d7f13987c933caa0e41b09316619c17958
2 changes: 2 additions & 0 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ call fails (for example because the path doesn't exist).
This method normally follows symlinks; to check if a symlink exists, add
the argument ``follow_symlinks=False``.

::

>>> Path('.').exists()
True
>>> Path('setup.py').exists()
Expand Down
4 changes: 4 additions & 0 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,10 @@ def link_to(self, target):
def exists(self, follow_symlinks=True):
Comment thread
akulakov marked this conversation as resolved.
Outdated
"""
Whether this path exists.

If path is a symlink: with `follow_symlinks=True`, return True if path
pointed to by the symlink exists; with follow_symlinks=False, return
True if the symlink itself exists.
Comment thread
barneygale marked this conversation as resolved.
Outdated
"""
try:
self.stat(follow_symlinks=follow_symlinks)
Expand Down