pathlib: why and how to use it
summary
Argues that pathlib.Path replaces stringly file handling with a concrete type, shows methods like read_text and mkdir(parents=True), demonstrates joining with the slash operator, and notes copy and copy_into land in Python 3.14 and PEP 519 makes open accept Path on 3.6. Shows interoperability with Django pandas pillow pytest click, warns against Path.open and unnecessary str conversions, and reports a search over 400,000 files where Path performance only degrades after converting all results back to Path objects.
AI-written summary · about
chapters (8)
- 0:00Introduction
- 1:54String-based path problems
- 6:54Why pathlib helps
- 10:05pathlib vs legacy modules
- 13:23How pathlib works
- 18:18Usage and best practices
- 22:19pathlib mistakes
- 24:46Performance and conclusion
related talks
16mElegant Filesystem Interactions in Python using pathlib
30m"Hot: Pathlib, Not: String Paths"
30m"Adding File System context to pathlib"
31mIntroduce Syntax and History of Python from 2.4 to 3.6
43mWhy do I need to know Python- I'm a pandas user
01h 18mIntroducing More of the Standard Library
43mPython Improvements (or This Is Not Your Teacher's Python)
01h 00mKeynote: Python now and in the future
