🔵 🔵 🔵


Primary

၊၊||၊|။

Path.iterdir() ⚬|Documentation|1st|20260130114848-00-⌔

pathlib — Object-oriented filesystem paths — Python 3.14.2 documentation#pathlib.Path.iterdir

Path.iterdir()

When the path points to a directory, yield path objects of the directory contents:

>>> p = Path('docs')
>>> for child in p.iterdir(): child
...
PosixPath('docs/conf.py')
PosixPath('docs/_templates')
PosixPath('docs/make.bat')
PosixPath('docs/index.rst')
PosixPath('docs/_build')
PosixPath('docs/_static')
PosixPath('docs/Makefile')

The children are yielded in arbitrary order, and the special entries '.' and '..' are not included. If a file is removed from or added to the directory after creating the iterator, it is unspecified whether a path object for that file is included.

If the path is not a directory or otherwise inaccessible, OSError is raised.

Printed 2026-06-28.

(echo:: @ )

Link to original

Secondary

• • •