Path objects join segments according to filesystem rules. An absolute later segment can replace the earlier base.
Worked example
from pathlib import PurePosixPath
print(PurePosixPath('data') / '2026' / 'report.csv')Result
data/2026/report.csvImplementation notes
Construct paths from trusted base directories and explicit segments. A path that is syntactically well formed can still point somewhere unintended.
Try it yourself
Compare a relative child with a child beginning at the filesystem root.
Open the Python example →Editorial date July 10, 2025 · Published December 6, 2026