O'Reilly logo

Python Essentials by Steven F. Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10. Files, Databases, Networks, and Contexts

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required