The Python standard library contains well over 200 modules, although the exact number varies between distributions. Not all of these modules are recommended for use by the typical Python programmer; many have specialized uses associated with the Python internal modules and are intended mainly for use by developers working on Python itself. And certain other modules, remnants of older Python versions now superseded by more modern alternatives, are retained mainly for compatibility with old code.
This appendix lists all of the standard packages and modules that are recommended for “normal use” and highlights, in bold, those used or discussed in this book. Modules marked in the official documentation as deprecated, or intended for use by core developers, as well as some designed to be development tools, have been omitted from the list. A few minor clarifications to the descriptions have been added. Not all packages have been expanded to show the individual modules, and in these cases a package-level description is provided.
aifc | Read and write audio files in AIFF or AIFC format. |
argparse | Command-line option and argument-parsing library. |
array | Space-efficient arrays of uniformly typed numeric values. |
asynchat | Support for asynchronous command/response protocols. |
asyncio | Asynchronous I/O, event loop, coroutines, and tasks. |
asyncore | A base class for developing asynchronous socket-handling services. |
atexit | Register and execute cleanup functions. |
audioop | Manipulate raw audio data. |
base64 | RFC 3548: Base16, Base32, Base64 Data Encodings; Base85, and ASCII85. |
binascii | Tools for converting data to and from various ASCII-encoded binary representations. |
binhex | Encode and decode files in binhex4 format. |
bisect | Array bisection algorithms for binary searching. |
bz2 | Interfaces for bzip2 compression and decompression. |
calendar | Functions for working with calendars, including some emulation of the UNIX cal(1) program. |
cgi | Helpers for running Python scripts via the common gateway interface (CGI). |
cgitb | Configurable traceback handler for CGI scripts. |
chunk | Module to read Interchange File Format (IFF) chunks. |
cmath | Mathematical functions for complex numbers. |
cmd | Build line-oriented command interpreters. |
code | Facilities to implement read-eval-print loops. |
codecs | Encode and decode data and streams. |
collections | Container data types. |
collections.abc | Abstract base classes for containers. |
colorsys | Conversion functions between RGB and other color systems. |
compileall | Tools for byte-compiling all Python source files in a directory tree or some subset thereof. |
concurrent | Execute computations concurrently using threads or processes. |
configparser | Configuration file parser. |
contextlib | Utilities for with-statement contexts. |
copy | Shallow and deep copy operations. |
copyreg | Register pickle support functions. |
crypt (UNIX) | The crypt() function used to check UNIX passwords. |
csv | Write and read tabular data to and from comma-delimited data files. (Other delimiters can also be used.) |
ctypes | A foreign function library for Python. |
curses (UNIX) | An interface to the curses library, providing portable terminal handling. |
datetime | Basic date and time types. |
dbm | Interfaces to various key-value database formats. |
decimal | Implementation of the General Decimal Arithmetic Specification. |
difflib | Helper classes and functions for computing differences between objects. |
distutils | Support for building and installing Python modules into an existing Python installation. |
doctest | Test snippets of code appearing within docstrings. |
Package supporting the parsing, manipulating, and generating of e-mail messages, including MIME documents. | |
encodings | Package supporting various character encodings. |
enum | Implementation of an enumeration class. |
errno | Standard errno system symbols. |
fcntl (UNIX) | The fcntl() and ioctl() system calls. |
filecmp | Compare files efficiently. |
fileinput | Loop over standard input or a list of files. |
fnmatch | UNIX shell–style filename pattern matching. |
fractions | Rational numbers. |
ftplib | FTP protocol client (requires sockets). |
functools | Higher-order functions and operations on callable objects. |
getpass | Portable reading of passwords and retrieval of the user ID. |
gettext | Multilingual internationalization services. |
glob | UNIX shell–style pathname pattern expansion. |
grp (UNIX) | The group database (getgrnam() and friends). |
gzip | Interfaces for gzip compression and decompression using file objects. |
hashlib | Secure hash and message digest algorithms. |
heapq | Heap queue algorithm (aka, priority queue). |
hmac | Keyed-Hashing for Message Authentication (HMAC) implementation for Python. |
html.entities | Data structures useful for processing HTML. |
html.parser | A simple parser that can handle HTML and XHTML. |
http | Package supporting use of HTTP including client, server, and cookie management. |
http.server | HTTP server and request handlers. |
imaplib | IMAP4 protocol client (requires sockets). |
imghdr | Determine the type of image contained in a file or byte stream. |
io | Core tools for working with streams. |
ipaddress | IPv4/IPv6 manipulation library. |
itertools | Functions creating iterators for efficient looping. |
json | Encode and decode the JSON data format. |
keyword | Test whether a given string is a Python keyword. |
linecache | Provides random access to individual lines from text files using a cache. |
locale | Internationalization services. |
logging | Flexible event logging for applications. |
lzma | A Python wrapper for the liblzma compression library. |
macpath | Mac OS 9 path manipulation functions. |
mailbox | Manipulate mailboxes in various formats. |
mailcap | Mailcap file handling. |
math | Mathematical functions [sin() , and so on]. |
mimetypes | Mapping of filename extensions to MIME types. |
mmap | Interface to memory-mapped files for UNIX and Windows. |
msvcrt (Windows) | Miscellaneous useful routines from the MS VC++ run time. |
multiprocessing | Package for process-based parallelism. |
netrc | Loading of .netrc files. |
nis (UNIX) | Interface to Sun’s NIS (Yellow Pages) library. |
nntplib | NNTP protocol client (requires sockets). |
numbers | Abstract base classes for numeric types (Complex, Real, Integral, and so on). |
operator | Functions corresponding to the standard operators (add, subtract, and so on). |
os |
Miscellaneous operating system interfaces. As Chapter 2 makes clear, the os module is one of several modules used to interact with the OS on Python, and the selection of functions provided is somewhat arbitrary and inconsistent. |
os.path | Provides helper functions for manipulating and testing file paths. |
ossaudiodev (Linux, FreeBSD) | Access to OSS-compatible audio devices. |
pathlib | Provides an object-oriented model of file system paths. |
pdb | A debugger for interactive Python interpreters. |
pickle | Convert Python objects to streams of bytes and back. |
pipes (UNIX) | A Python interface to UNIX shell pipelines. |
platform | Retrieves as much platform identifying data as possible. |
plistlib | Generate and parse Mac OS X plist files. |
poplib | POP3 protocol client (requires sockets). |
pprint | Pretty prints Python data structures. |
profile | Python source code profiler. |
pstats | Statistics object for use with the profiler. |
pty (Linux) | Handling of pseudo-terminals for Linux. |
pwd (UNIX) | The password database [getpwnam() and friends]. |
queue | A queue class suitable for communicating between threads. |
quopri | Encode and decode files using the MIME quoted-printable encoding. |
random | Generate pseudorandom numbers with various common distributions. |
re | Regular-expression operations. |
readline (UNIX) | GNU readline support for Python. |
reprlib | An alternate repr() implementation with size limits. |
resource (UNIX) | An interface to provide resource usage information about the current process. |
sched | General-purpose event scheduler. |
select | Wait for I/O completion on multiple streams. |
selectors | High-level I/O multiplexing. |
shelve | Python object persistence. |
shlex | Simple lexical analysis for UNIX shell–like languages. |
shutil | High-level file operations, including copying. |
signal | Set handlers for asynchronous events. |
smtpd | An SMTP server implementation in Python. |
smtplib | SMTP protocol client (requires sockets). |
sndhdr | Determine the type of sound file. |
socket | Low-level networking interface. |
socketserver | A framework for network servers. |
spwd (UNIX) | The shadow password database [getspnam() and friends]. |
sqlite3 | A DB-API 2.0 implementation using SQLite 3.x. |
ssl | TLS/SSL wrapper for socket objects. |
stat | Utilities for interpreting the results of os.stat() , os.lstat() , and os.fstat() . |
statistics | Mathematical statistics functions. |
string | Common string operations. |
stringprep | String preparation, as per RFC 3453. |
struct | Read and write binary data in a byte array. |
subprocess | Subprocess management. |
sunau | Provide an interface to the Sun AU sound format. |
sys | Access system-specific parameters and functions. |
sysconfig | Python’s configuration information. |
syslog (UNIX) | An interface to the UNIX syslog library routines. |
tarfile | Read and write tar-format archive files. |
telnetlib | Telnet client class. |
tempfile | Generate temporary files and directories. |
termios (UNIX) | POSIX style TTY control. |
textwrap | Text wrapping and filling. |
threading | Parallel processing based on threads. |
time | Time access and conversions. |
timeit | Measure the execution time of code snippets. |
tkinter | Interface to Tcl/Tk for graphical user interfaces. |
tkinter.messagebox | Standard message dialogs. |
tkinter.tix | Tk Extension Widgets for Tkinter. |
tkinter.ttk | Tk themed widget set. |
tkinter.filedialog | Variations on standard File dialogs. |
tkinter.simpledialog | A base class for building custom dialogs. |
tty (UNIX) | Utility functions that perform common terminal control operations. |
turtle | An educational framework for developing simple graphics applications. |
types | Names for Python’s built-in types. |
unicodedata | Access the Unicode database. |
unittest | Unit testing framework for Python. |
urllib | Package for processing URLs including requests, responses, errors, and so on. |
uu | Encode and decode file-like objects to and from uuencode format. |
uuid | UUID objects (universally unique identifiers) according to RFC 4122. |
warnings | Issue warning messages and control their disposition. |
wave | Provide an interface to the WAV sound format. |
weakref | Support for weak references and weak dictionaries. |
webbrowser | Easy-to-use controller for web browsers. |
win32com.client | Third-party module providing access to the native Win32 API. |
winreg (Windows) | Provides helper functions and a Key class for manipulating the Windows registry. |
winsound (Windows) | Access to the sound-playing machinery for Windows. |
wsgiref | Package providing a reference implementation of WSGI along with various WSGI utility functions and classes. |
xdrlib | Encoders and decoders for the External Data Representation (XDR). |
xml | Package containing XML processing modules. |
xml.dom | Document object model (DOM) API for Python. |
xml.minidom | Minimal document object model (DOM) implementation. |
xml.etree | Implementation of the ElementTree API. |
Xml.parsers.expat | An interface to the Expat non-validating XML parser. |
xml.sax | Package containing SAX2 base classes and convenience functions. |
xml.sax.handler | Base classes for SAX event handlers. |
xmlrpc | Package providing support for XMLRPC. |
Xmlrpc.client | Provides helper functions and classes for XML-RPC client access. |
Xmlrpc.server | Basic XML-RPC server implementations. |
zipfile | Read and write zip-format archive files. |
zlib | Low-level interface to compression and decompression routines compatible with gzip. |