File I/O
Our examples so far that have touched the filesystem have operated entirely on text files without much thought as to what is going on under the hood. Operating systems represent files as a sequence of bytes, not text. We'll take a deep dive into the relationship between bytes and text in Chapter 9, Strings, Serialization, and File Paths. For now, be aware that reading textual data from a file is a fairly involved process, but Python takes care of most of the work for us behind the scenes.
The concept of files has been around since long before anyone coined the term object-oriented programming. However, Python has wrapped the interface that operating systems provide in a sweet abstraction that allows us to work with file (or file-like, vis-à-vis duck typing) objects.
The confusion arises because the operating system file and the Python file object are both, commonly, called "files." It's difficult to be ultra-cautious and...