diff options
author | Barney Gale <barney.gale@gmail.com> | 2024-11-01 01:19:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-01 01:19:01 (GMT) |
commit | 260843df1bd8a28596b9a377d8266e2547f7eedc (patch) | |
tree | db6186d963dee64b6448445ea726a9e611453813 /Lib/pathlib/_local.py | |
parent | d0abd0b826cfa574d1515c6f8459c9901939388f (diff) | |
download | cpython-260843df1bd8a28596b9a377d8266e2547f7eedc.zip cpython-260843df1bd8a28596b9a377d8266e2547f7eedc.tar.gz cpython-260843df1bd8a28596b9a377d8266e2547f7eedc.tar.bz2 |
GH-125413: Add `pathlib.Path.scandir()` method (#126060)
Add `pathlib.Path.scandir()` as a trivial wrapper of `os.scandir()`. This
will be used to implement several `PathBase` methods more efficiently,
including methods that provide `Path.copy()`.
Diffstat (limited to 'Lib/pathlib/_local.py')
-rw-r--r-- | Lib/pathlib/_local.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/pathlib/_local.py b/Lib/pathlib/_local.py index a789971..ef072b8 100644 --- a/Lib/pathlib/_local.py +++ b/Lib/pathlib/_local.py @@ -615,6 +615,14 @@ class Path(PathBase, PurePath): path_str = path_str[:-1] yield path_str + def scandir(self): + """Yield os.DirEntry objects of the directory contents. + + The children are yielded in arbitrary order, and the + special entries '.' and '..' are not included. + """ + return os.scandir(self) + def iterdir(self): """Yield path objects of the directory contents. |