The Python Library

Python comes with an extensive library, structured as a collection of modules. A few modules are built into the interpreter: these generally provide access to system libraries implemented in C such as mathematical functions or operating system calls. Two built-in modules provide access to internals of the interpreter and its environment. Even abusing these internals will at most cause an exception in the Python program; the interpreter will not dump core because of errors in Python code.

Most modules however are written in Python and distributed with the interpreter; they provide general programming tools like string operations and random number generators, provide more convenient interfaces to some built-in modules, or provide specialized services like a getopt-style command line option processor for stand-alone scripts.

There are also some modules written in Python that dig deep in the internals of the interpreter; there is a module to browse the stack backtrace when an unhandled exception has occurred, one to disassemble the internal representation of Python code, and even an interactive source code debugger which can trace Python code, set breakpoints, etc.