Python pathlib is the modern way to handle file paths. But I always forget how to break apart a path into components (directory part, filename part, etc.). This image is a cheat-sheet for working with Path, breaking it apart into root, directory path, filename, suffix, etc.
![](http://yager-research.ca/wp-content/uploads/2023/11/rect1042-1024x648.png)