If you’d like a visual representation of these and other properties and methods, then check out Pathlib Cheatsheet.
Picking Out Components of a Path
Picking Out Components of a Path. One of the most convenient features of
Path is that different parts are available as properties. Basic examples include
.name, the file name without any directory;
.parent, the directory containing the file, or the parent directory if the path is a directory;
.stem, the filename without the suffix;
.suffix, the file extension; and
.anchor, the part of the path before the directories.
The excellent Pathlib Cheatsheet provides a visual representation of these and other properties and methods. In the next section of the course, you’ll take a look at some of the finer details of the
Become a Member to join the conversation.