Filesystem paths
Most operating systems provide a filesystem, a way of mapping a logical abstraction of directories (often depicted as folders) and files to the bits and bytes stored on a hard drive or another storage device. As humans, we typically interact with the filesystem using a drag-and-drop interface with images of folders and files of different types. Or we can use command-line programs such as cp
, mv
, and mkdir
.
As programmers, we have to interact with the filesystem with a series of system calls. You can think of these as library functions supplied by the operating system so that programs can call them. They have a clunky interface with integer file handles and buffered reads and writes, and that interface is different depending on which operating system you are using. The Python os
module exposes some of these underlying calls.
Inside the os
module is the os.path
module. While it works, it's not very intuitive. It requires...