The next two sections will take a quick tour through
os, before this chapter
moves on to larger system programming concepts. As I’m not
going to demonstrate every item in every built-in module, the first
thing I want to do is show you how to get more details on your own.
Officially, this task also serves as an excuse for introducing a few
core system scripting concepts -- along the way, we’ll code
a first script to format documentation.
Most system-level interfaces in Python are shipped in just two
That’s somewhat oversimplified; other standard modules belong
to this domain too (e.g.,
fcntl), and some built-in
functions are really system interfaces as well (e.g.,
os together form the core of Python’s system
In principle at least,
sys exports components
related to the Python interpreter itself (e.g.,
the module search path), and
os contains variables
and functions that map to the operating system on which Python is
run. In practice, this distinction may not always seem clear-cut
(e.g., the standard input and output streams show up in
sys, but they are at least arguably tied to
operating system paradigms). The good news is that you’ll soon
use the tools in these modules so often that their locations will be
permanently stamped on your memory.
os module also attempts to provide a
portable programming interface to the underlying operating system ...