Python Pathlib Guide
A guide to handling filesystem paths elegantly with Python's pathlib module for cross-platform compatibility.
Usage
Ask about pathlib operations, file handling, glob patterns, or migration from os.path.
Examples
- "Find all Python files recursively with pathlib"
- "How do I read and write files with pathlib?"
- "Construct cross-platform file paths"
Guidelines
- Use Path() over os.path for cleaner, more readable code
- Use the / operator for path concatenation
- Use .resolve() to get absolute paths
- Use .glob() and .rglob() for pattern-based file discovery
- Use .with_suffix() and .with_name() for path manipulation