Elegant Filesystem Interactions in Python using pathlib

By Johan Herland

Anyone who has written python code to manipulate files and directories, will be familiar with the os and os.path modules. Starting with Python v3.4, there’s a new kid on the block - pathlib - which provides a fresh interface to querying and manipulating the filesystem.

This short session will introduce pathlib, and demonstrate how it can be used to avoid littering your code with calls to os.path.* functions. We will go through examples of how rewriting code to use pathlib makes it shorter and more readable.

Finally, we will conclude with a look ahead, noting where pathlib still has some ways to go before it has become a fully integrated part of Python.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.