0Pricing
Python Academy · Lesson

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

  1. The Path Object
  2. Reading and Writing Files
  3. Globbing and Iterating
  4. Path Manipulation
← Back to Python Academy