PyBeach 2025 - Trey Hunner - pathlib: why and how to use it

Опубликовано: 11 Июнь 2026
на канале: PyBeach
310
like

If your Python code works with file paths, you should be using `pathlib`. This standard library module may seem a bit cumbersome at first, but `pathlib`-using code is often more readable the alternative.

Python's many path-oriented utilities used to expect a string representation for all file paths. That's not the case anymore. Now, every important path-consuming library will accept `pathlib.Path` objects.

During this talk, we see why `pathlib.Path` objects make for more maintainable code. We'll visit a number of useful `pathlib` examples and recipes along the way.

By the end of this talk, you'll be tempted to convert all your path-handling code to use `pathlib`.

This talk was from PyBeach 2025, a community-run Python programming conference in the Los Angeles area. Check us out at https://pybeach.org