- If you can’t find the manuals on your computer, you can always read them online.
Go to Python’s website at http://www.python.org and follow the documentation
links there. This website also has a simple searching utility for the manuals.
However you get started, be sure to pick the Library manual for things such as sys; this
manual documents all of the standard library, built-in types and functions, and more.
Python’s standard manual set also includes a short tutorial, a language reference, ex-
tending references, and more.
Commercially Published References
At the risk of sounding like a marketing droid, I should mention that you can also
purchase the Python manual set, printed and bound; see the book information page at
http://www.python.org for details and links. Commercially published Python reference
books are also available today, including Python Essential Reference, Python in a Nut-
shell, Python Standard Library, and Python Pocket Reference. Some of these books are
more complete and come with examples, but the last one serves as a convenient memory
jogger once you’ve taken a library tour or two.†
Introducing the sys Module
But enough about documentation sources (and scripting basics)—let’s move on to
system module details. As mentioned earlier, the sys and os modules form the core of
much of Python’s system-related tool set. To see how, we’ll turn to a quick, interactive
tour through some of the tools in these two modules before applying them in bigger
examples. We’ll start with sys, the smaller of the two; remember that to see a full list
of all the attributes in sys, you need to pass it to the dir function (or see where we did
so earlier in this chapter).
Platforms and Versions
Like most modules, sys includes both informational names and functions that take
action. For instance, its attributes give us the name of the underlying operating system
on which the platform code is running, the largest possible “natively sized” integer on
this machine (though integers can be arbitrarily long in Python 3.X), and the version
number of the Python interpreter running our code:
C:\...\PP4E\System> python
>>> import sys
† Full disclosure: I also wrote the last of the books listed as a replacement for the reference appendix that
appeared in the first edition of this book; it’s meant to be a supplement to the text you’re reading, and its
latest edition also serves as a translation resource for Python 2.X readers. As explained in the Preface, the
book you’re holding is meant as tutorial, not reference, so you’ll probably want to find some sort of reference
resource eventually (though I’m nearly narcissistic enough to require that it be mine).
86 | Chapter 2: System Tools