ID EN
Pathlib

parents

Python 3.11

An immutable sequence providing access to the logical ancestors of the path:

Syntax

PYTHON
PurePath.parents

Examples

Example 1
PYTHON
>>> p = PureWindowsPath('c:/foo/bar/setup.py')
>>> p.parents[0]
PureWindowsPath('c:/foo/bar')
>>> p.parents[1]
PureWindowsPath('c:/foo')
>>> p.parents[2]
PureWindowsPath('c:/')

See Also

slices