Table of Contents
This chapter covers some more advanced topics. the section called “The math Module” covers two important modules,
math and random. the section called “Division Operators” covers the important distinction between the
division operators. We also provide some supplemental information that is
more specialized. the section called “Bit Manipulation Operators” covers some
additional bit-fiddling operators that work on the basic numeric types.
the section called “Expression Style Notes” has some notes on style.
A Python module extends the Python execution environment by adding new classes, functions and helpful constants. We tell the Python interpreter to fetch a module with a variation on the import statement. There are several variations on import, which we'll cover in depth in Part IV, “Components, Modules and Packages”.
For now, we'll use the simple import:
import m
This will import module m. Only the module's
name, m is made available. Every name inside the
module m must be qualified
by prepending the module name and a .. So if module
m had a function called spam,
we'd refer to it as m.spam.
There are dozens of standard Python modules. We'll get to the most important ones in Part IV, “Components, Modules and Packages”. For now, we'll focus on extending the math capabilities of the basic expressions we've looked so far.