maintained, and reused. When using Python, there is no need to start every new script
from scratch.
Moreover, we’ll find that Python not only includes all the interfaces we need in order
to write system tools, but it also fosters script portability. By employing Python’s stand-
ard library, most system scripts written in Python are automatically portable to all major
platforms. For instance, you can usually run in Linux a Python directory-processing
script written in Windows without changing its source code at all—simply copy over
the source code. Though writing scripts that achieve such portability utopia requires
some extra effort and practice, if used well, Python could be the only system scripting
tool you need to use.
The Next Five Chapters
To make this part of the book easier to study, I have broken it down into five chapters:
- In this chapter, I’ll introduce the main system-related modules in overview fashion.
We’ll meet some of the most commonly used system tools here for the first time. - In Chapter 3, we continue exploring the basic system interfaces by studying their
role in core system programming concepts: streams, command-line arguments,
environment variables, and so on. - Chapter 4 focuses on the tools Python provides for processing files, directories,
and directory trees. - In Chapter 5, we’ll move on to cover Python’s standard tools for parallel
processing—processes, threads, queues, pipes, signals, and more. - Chapter 6 wraps up by presenting a collection of complete system-oriented pro-
grams. The examples here are larger and more realistic, and they use the tools
introduced in the prior four chapters to perform real, practical tasks. This collection
includes both general system scripts, as well as scripts for processing directories of
files.
Especially in the examples chapter at the end of this part, we will be concerned as much
with system interfaces as with general Python development concepts. We’ll see non-
object-oriented and object-oriented versions of some examples along the way, for in-
stance, to help illustrate the benefits of thinking in more strategic ways.
“Batteries Included”
This chapter, and those that follow, deal with both the Python language and its standard
library—a collection of precoded modules written in Python and C that are automat-
ically installed with the Python interpreter. Although Python itself provides an easy-to-
use scripting language, much of the real action in Python development involves this
vast library of programming tools (a few hundred modules at last count) that ship with
the Python package.
74 | Chapter 2: System Tools