PurePath.parent
The logical parent of the path:
>>> p = PurePosixPath('/a/b/c/d')
>>> p.parent
PurePosixPath('/a/b/c')
You cannot go past an anchor, or empty path:
>>> p = PurePosixPath('/')
>>> p.parent
PurePosixPath('/')
>>> p = PurePosixPath('.')
>>> p.parent
PurePosixPath('.')
Note
This is a purely lexical operation, hence the following behaviour:
>>> p = PurePosixPath('foo/..')
>>> p.parent
PurePosixPath('foo')
If you want to walk an arbitrary filesystem path upwards, it is recommended to first call Path.resolve() so as to resolve symlinks and eliminate ”..” components.
Please login to continue.