Files and the filesystem are central to the way modern OSs work. Many OS resources are visible as part of the filesystem. For example, the Linux
/dev/mem is a view into the processor's memory, implemented as a device visible in the filesystem. Python provides file objects that map to these OS features.
At a fundamental level, OS files are simply collections of bytes. In practice, we often work with files that are collections of Unicode characters. Python offers both views of files. With some file formats, we need to process the bytes. With text files, we expect Python to properly decode Unicode characters from the bytes.
A Python file object will generally be entangled with an OS resource. In ...