On this page
pathlib.PurePosixPath
Prev: pathlib.PurePath | Up: pathlib | Next: pathlib.PureWindowsPath
Rel: pathlib.Path, pathlib.PosixPath, pathlib.PurePath, pathlib.PureWindowsPath
Ref: docs.python.org — pathlib.PurePosixPath
Tags: #public #python3 #stdlib #pathlib
Import
import pathlib
from pathlib import PurePosixPath
Signature & Overview
pathlib.PurePosixPath(*args, **kwargs)
PurePath subclass for non-Windows systems.
Methods & Attributes
PurePosixPath.anchor(...)— The concatenation of the drive and root, or ''.PurePosixPath.as_posix(self)— Return the string representation of the path with forward (/) slashes.PurePosixPath.as_uri(self)— Return the path as a URI.PurePosixPath.drive(...)— The drive prefix (letter or UNC path), if any.PurePosixPath.full_match(self, pattern, *, case_sensitive=None)— Return True if this path matches the given glob-style pattern. The pattern is matched against the entire path.PurePosixPath.is_absolute(self)— True if the path is absolute (has both a root and, if applicable, a drive).PurePosixPath.is_relative_to(self, other)— Return True if the path is relative to another path or False.PurePosixPath.is_reserved(self)— Return True if the path contains one of the special names reserved by the system, if any.PurePosixPath.joinpath(self, *pathsegments)— Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments isPurePosixPath.match(self, path_pattern, *, case_sensitive=None)— Return True if this path matches the given pattern. If the pattern is relative, matching is done from the right; otherwise, the entire path is matched. The recursive wildcard '**' is not supported by thisPurePosixPath.name(...)— The final path component, if any.PurePosixPath.parent(...)— The logical parent of the path.PurePosixPath.parents(...)— A sequence of this path's logical parents.PurePosixPath.parts(...)— An object providing sequence-like access to the components in the filesystem path.PurePosixPath.relative_to(self, other, *, walk_up=False)— Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not related to the other path), raise ValueError.PurePosixPath.root(...)— The root of the path, if any.PurePosixPath.stem(...)— The final path component, minus its last suffix.PurePosixPath.suffix(...)— The final component's last suffix, if any.PurePosixPath.suffixes(...)— A list of the final component's suffixes, if any.PurePosixPath.with_name(self, name)— Return a new path with the file name changed.PurePosixPath.with_segments(self, *pathsegments)— Construct a new path object from any number of path-like objects.PurePosixPath.with_stem(self, stem)— Return a new path with the stem changed.PurePosixPath.with_suffix(self, suffix)— Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path.
Usage
from pathlib import PurePosixPath
# Works identically on Windows, macOS, and Linux (great for URLs, S3 keys, Docker paths)
key = PurePosixPath("releases") / "2026" / "app.tar.gz"
assert str(key) == "releases/2026/app.tar.gz"
assert key.suffixes == [".tar", ".gz"]
assert key.parent == PurePosixPath("releases/2026")
Gotchas
- Pure string computation: Never touches the local filesystem—safe for remote Linux paths, container paths, and archive members on any OS.
- No
..normalization:PurePosixPath("/a/b/../c")keeps".."literally; collapsing symlinks/parent segments requires concretePath.resolve().
REPL Inspect
from pathlib import PurePosixPath
help(PurePosixPath)
Linked from
- tuts/python3/stdlib_module/pathlib
- tuts/python3/stdlib_module/pathlib/Path
- tuts/python3/stdlib_module/pathlib/PosixPath
- tuts/python3/stdlib_module/pathlib/PurePath
- tuts/python3/stdlib_module/pathlib/PureWindowsPath
- tuts/python3/stdlib_module/pathlib/UnsupportedOperation
- tuts/python3/stdlib_module/pathlib/WindowsPath
Related notes
- tuts/python3/stdlib_module/pathlib/Path Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PosixPath Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PurePath Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/PureWindowsPath Linked here; links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/pathlib/UnsupportedOperation links to this page; shared tags: #pathlib, #stdlib
- tuts/python3/stdlib_module/pathlib/WindowsPath links to this page; shared tags: #pathlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib