Category: pathlib

Problem

Modern path manipulation with pathlib.

Solution

  for py in Path("src").rglob("*.py"):
    print(py.read_text()[:80])
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path