summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorBarney Gale <barney.gale@gmail.com>2023-06-26 16:58:17 (GMT)
committerGitHub <noreply@github.com>2023-06-26 16:58:17 (GMT)
commit219effa876785408a87bd6acb37c07ee0d25f3f9 (patch)
treee23207f21e6fb329be9ba41c4a3321aab1600894 /Doc/library
parent5d4dbf0e309255e5bce9e31d805a8f950ebf9161 (diff)
downloadcpython-219effa876785408a87bd6acb37c07ee0d25f3f9.zip
cpython-219effa876785408a87bd6acb37c07ee0d25f3f9.tar.gz
cpython-219effa876785408a87bd6acb37c07ee0d25f3f9.tar.bz2
GH-105793: Add follow_symlinks argument to `pathlib.Path.is_dir()` and `is_file()` (GH-105794)
Brings `pathlib.Path.is_dir()` and `in line with `os.DirEntry.is_dir()`, which will be important for implementing generic path walking and globbing. Likewise `is_file()`.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/pathlib.rst24
1 files changed, 18 insertions, 6 deletions
diff --git a/Doc/library/pathlib.rst b/Doc/library/pathlib.rst
index 9bbfe38..3385754 100644
--- a/Doc/library/pathlib.rst
+++ b/Doc/library/pathlib.rst
@@ -978,23 +978,35 @@ call fails (for example because the path doesn't exist).
available. In previous versions, :exc:`NotImplementedError` was raised.
-.. method:: Path.is_dir()
+.. method:: Path.is_dir(*, follow_symlinks=True)
- Return ``True`` if the path points to a directory (or a symbolic link
- pointing to a directory), ``False`` if it points to another kind of file.
+ Return ``True`` if the path points to a directory, ``False`` if it points
+ to another kind of file.
``False`` is also returned if the path doesn't exist or is a broken symlink;
other errors (such as permission errors) are propagated.
+ This method normally follows symlinks; to exclude symlinks to directories,
+ add the argument ``follow_symlinks=False``.
-.. method:: Path.is_file()
+ .. versionchanged:: 3.13
+ The *follow_symlinks* parameter was added.
+
+
+.. method:: Path.is_file(*, follow_symlinks=True)
- Return ``True`` if the path points to a regular file (or a symbolic link
- pointing to a regular file), ``False`` if it points to another kind of file.
+ Return ``True`` if the path points to a regular file, ``False`` if it
+ points to another kind of file.
``False`` is also returned if the path doesn't exist or is a broken symlink;
other errors (such as permission errors) are propagated.
+ This method normally follows symlinks; to exclude symlinks, add the
+ argument ``follow_symlinks=False``.
+
+ .. versionchanged:: 3.13
+ The *follow_symlinks* parameter was added.
+
.. method:: Path.is_junction()