"Hot: Pathlib, Not: String Paths"
summary
Live demo replaces os.path strings with pathlib Path objects showing concrete methods and results: creating paths (Path, PurePath, platform-specific Windows/Posix classes), joining with '/', Path objects are hashable so they work as set keys, mkdir(parents=True, exist_ok=True) creates deep trees, touch/write_text/read_text create and read files, glob/rglob and new walk return iterative results, resolve vs absolute with resolve(..., strict=True) raises if target missing, unlink/rmdir/replace delete, and a cleanup script runs and successfully removes the created tree.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 1:05String path problems
- 3:12PurePath vs Path objects
- 4:16Creating path objects
- 6:48Path properties and manipulation
- 9:19Modifying path names
- 10:23Relative paths and resolution
- 11:48Joining and directory ops
- 13:36Checking and creating dirs
- 15:42Listing, globbing, removing
- 16:05File existence and creation
- 17:08Reading and writing files
- 18:11File metadata access
- 18:53Renaming, replacing, deleting
- 19:58Advanced filesystem checks
- 20:59Recursive cleanup function
- 22:03Pathlib in Python stdlib
- 22:44Live demo script
- 28:16Q&A
related talks
27mpathlib: why and how to use it
16mElegant Filesystem Interactions in Python using pathlib
30m"Adding File System context to pathlib"
51mBuilding useful project utils in Python
25mThe Standard Library Tour
43mPython Improvements (or This Is Not Your Teacher's Python)
24mThursday Lightning Talks
21mUnderstanding the Magic of Python Modules and Packages
