Path Manipulation
Join, resolve, and inspect paths.
Inspecting and Transforming Paths
Beyond building paths, pathlib lets you resolve them to absolute form, test relationships between them, and read filesystem metadata, all without touching os.path.
Absolute vs Relative
is_absolute() reports whether a path is anchored at the root. Relative paths are interpreted against the current directory.
from pathlib import Path
print(Path('docs/file.txt').is_absolute())
print(Path('/usr/local').is_absolute())All lessons in this course
- The Path Object
- Reading and Writing Files
- Globbing and Iterating
- Path Manipulation