Python 3.4+pathlibterm
pathlib.PurePath
pure paths
A filesystem path for pure computation, with no I/O (name/suffix/parts/parent).
Syntax
pathlib.PurePath(*segments)
PurePath() is a factory: it gives you PureWindowsPath on Windows and PurePosixPath elsewhere, so name the flavour explicitly when you want deterministic behaviour in tests. A pure path has no .exists(), .open() or .iterdir() — everything that touches the disk lives on Path only. Paths of different flavours never compare equal, even when their strings are identical.
Examples
import pathlib
p = pathlib.PurePath('a/b/c.txt')
print(p.name, p.suffix) # → c.txt .txt
print(p.parts) # → ('a', 'b', 'c.txt')
See also
Open in the full glossarydocs.python.orgReport an inaccuracy