Previous Page
Next Page

10.2. Organization of This Chapter

First of all, this chapter, in "File Objects" on page 216, discusses the most typical way in which Python programs read and write data, which is via built-in file objects. Immediately after that, the chapter covers the polymorphic concept of file-like objects (objects that are not files but behave to some extent like files) in "File-Like Objects and Polymorphism" on page 222.

The chapter next covers modules that deal with temporary files and file-like objects (tempfile in "The tempfile Module" on page 223, StringIO and cStringIO in "The StringIO and cStringIO Modules" on page 229).

Next comes the coverage of modules that help you access the contents of text and binary files (fileinput in "The fileinput Module" on page 224, linecache in "The linecache Module" on page 226, struct in "The struct Module" on page 227) and support compressed files and other data archives (gzip in "The gzip Module" on page 230, bz2 in "The bz2 Module" on page 232, tarfile in "The tarfile Module" on page 233, zipfile in "The zipfile Module" on page 235, zlib in "The zlib Module" on page 239).

In Python, the os module supplies many of the functions that operate on the filesystem, so this chapter continues by introducing the os module in "The os Module" on page 240. The chapter then covers, in "Filesystem Operations" on page 241, operations on the filesystem (comparing, copying, and deleting directories and files, working with file paths, and accessing low-level file descriptors) offered by os (in "File and Directory Functions of the os Module" on page 242), os.path (in "The os.path Module" on page 246), and other modules (dircache in "listdir", stat in "The stat Module" on page 249, filecmp in "The filecmp Module" on page 250, and shutil in "The shutil Module" on page 252).

Many modern programs rely on a graphical user interface (GUI) (as covered in Chapter 17), but text-based, nongraphical user interfaces are still useful, since they're simple, fast to program, and lightweight. This chapter concludes with material about text input and output in Python in "Text Input and Output" on page 256, richer text I/O in "Richer-Text I/O" on page 258, interactive command-line sessions in "Interactive Command Sessions" on page 265, and, finally, information about presenting text that is understandable to different users, no matter where they are or what language they speak, in "Internationalization" on page 269. This subject is generally known as internationalization (often abbreviated i18n).


Previous Page
Next Page