PyDocs

Chapters

Python's Standard Library

Python 3.15.2 ships with 320 documented modules, from string handling to networking. They are grouped below the same way as in the official library reference.

We also have a page listing every function, class, and constant, and a quick reference by purpose.

Text Processing Services

difflib
Helpers for computing differences between objects.
re
Regular expression operations.
readline
GNU readline support for Python.
rlcompleter
Python identifier completion, suitable for the GNU readline library.
string
Common string operations.
string.templatelib
Support for template string literals.
stringprep
String preparation, as per RFC 3453
textwrap
Text wrapping and filling
unicodedata
Access the Unicode Database.

Binary Data Services

codecs
Encode and decode data and streams.
encodings
Encodings package
encodings.idna
Internationalized Domain Names implementation
encodings.mbcs
Windows ANSI codepage
encodings.utf_8_sig
UTF-8 codec with BOM signature
struct
Interpret bytes as packed binary data.

Data Types

array
Space efficient arrays of uniformly typed numeric values.
bisect
Array bisection algorithms for binary searching.
calendar
Functions for working with calendars, including some emulation of the Unix cal program.
collections
Container datatypes
collections.abc
Abstract base classes for containers
copy
Shallow and deep copy operations.
datetime
Basic date and time types.
enum
Implementation of an enumeration class.
graphlib
Functionality to operate with graph-like structures
heapq
Heap queue algorithm (a.k.a. priority queue).
pprint
Data pretty printer.
reprlib
Alternate repr() implementation with size limits.
types
Names for built-in types.
weakref
Support for weak references and weak dictionaries.
zoneinfo
IANA time zone support

Numeric and Mathematical Modules

cmath
Mathematical functions for complex numbers.
decimal
Implementation of the General Decimal Arithmetic Specification.
fractions
Rational numbers.
math
Mathematical functions (sin() etc.).
math.integer
Integer-specific mathematics functions.
numbers
Numeric abstract base classes (Complex, Real, Integral, etc.).
random
Generate pseudo-random numbers with various common distributions.
statistics
Mathematical statistics functions

Functional Programming Modules

functools
Higher-order functions and operations on callable objects.
itertools
Functions creating iterators for efficient looping.
operator
Functions corresponding to the standard operators.

File and Directory Access

filecmp
Compare files efficiently.
fnmatch
Unix shell style filename pattern matching.
glob
Unix shell style pathname pattern expansion.
linecache
Provides random access to individual lines from text files.
os.path
Operations on pathnames.
pathlib
Object-oriented filesystem paths
pathlib.types
pathlib types for static type checking
shutil
High-level file operations, including copying.
stat
Utilities for interpreting the results of os.stat(), os.lstat() and os.fstat().
tempfile
Generate temporary files and directories.

Data Persistence

copyreg
Register pickle support functions.
dbm
Interfaces to various Unix "database" formats.
dbm.dumb
Portable implementation of the simple DBM interface.
dbm.gnu
GNU database manager
dbm.ndbm
The New Database Manager
dbm.sqlite3
SQLite backend for dbm
marshal
Convert Python objects to streams of bytes and back (with different constraints).
pickle
Convert Python objects to streams of bytes and back.
shelve
Python object persistence.
sqlite3
A DB-API 2.0 implementation using SQLite 3.x.

Data Compression and Archiving

bz2
Interfaces for bzip2 compression and decompression.
compression
The compression package contains the canonical compression modules containing interfaces to several different compression algorithms.
compression.zstd
Low-level interface to compression and decompression routines in the zstd library.
gzip
Interfaces for gzip compression and decompression using file objects.
lzma
A Python wrapper for the liblzma compression library.
tarfile
Read and write tar-format archive files.
zipfile
Read and write ZIP-format archive files.
zlib
Low-level interface to compression and decompression routines compatible with gzip.

File Formats

configparser
Configuration file parser.
csv
Write and read tabular data to and from delimited files.
netrc
Loading of .netrc files.
plistlib
Generate and parse Apple plist files.
tomllib
Parse TOML files.

Cryptographic Services

hashlib
Secure hash and message digest algorithms.
hmac
Keyed-Hashing for Message Authentication (HMAC) implementation
secrets
Generate secure random numbers for managing secrets.

Generic Operating System Services

ctypes
A foreign function library for Python.
ctypes.wintypes
Windows data types for ctypes.
errno
Standard errno system symbols.
io
Core tools for working with streams.
logging
Flexible event logging system for applications.
logging.config
Configuration of the logging module.
logging.handlers
Handlers for the logging module.
os
Miscellaneous operating system interfaces.
platform
Retrieves as much platform identifying data as possible.
time
Time access and conversions.

Command-line interface libraries

argparse
Command-line option and argument parsing library.
cmd
Build line-oriented command interpreters.
curses
An interface to the curses library, providing portable terminal handling.
curses.ascii
Constants and set-membership functions for ASCII characters.
curses.panel
A panel stack extension that adds depth to curses windows.
curses.textpad
Emacs-like input editing in a curses window.
fileinput
Loop over standard input or a list of files.
getpass
Portable reading of passwords and retrieval of the userid.
optparse
Command-line option parsing library.

Concurrent Execution

_thread
Low-level threading API.
concurrent.futures
Execute computations concurrently using threads or processes.
concurrent.interpreters
Multiple interpreters in the same process
contextvars
Context Variables
multiprocessing
Process-based parallelism.
multiprocessing.connection
API for dealing with sockets.
multiprocessing.dummy
Dumb wrapper around threading.
multiprocessing.managers
Share data between process with shared objects.
multiprocessing.pool
Create pools of processes.
multiprocessing.shared_memory
Provides shared memory for direct access across processes.
multiprocessing.sharedctypes
Allocate ctypes objects from shared memory.
queue
A synchronized queue class.
sched
General purpose event scheduler.
subprocess
Subprocess management.
threading
Thread-based parallelism.

Networking and Interprocess Communication

asyncio
Asynchronous I/O.
mmap
Interface to memory-mapped files for Unix and Windows.
select
Wait for I/O completion on multiple streams.
selectors
High-level I/O multiplexing.
signal
Set handlers for asynchronous events.
socket
Low-level networking interface.
ssl
TLS/SSL wrapper for socket objects

Internet Data Handling

base64
RFC 4648: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85
binascii
Tools for converting between binary and various ASCII-encoded binary representations.
email
Package supporting the parsing, manipulating, and generating email messages.
email.charset
Character Sets
email.contentmanager
Storing and Retrieving Content from MIME Parts
email.encoders
Encoders for email message payloads.
email.errors
The exception classes used by the email package.
email.generator
Generate flat text email messages from a message structure.
email.header
Representing non-ASCII headers
email.headerregistry
Automatic Parsing of headers based on the field name
email.iterators
Iterate over a message object tree.
email.message
The base class representing email messages.
email.mime
Build MIME messages.
email.mime.application
Class representing application/* type MIME documents.
email.mime.audio
Class representing audio/* type MIME documents.
email.mime.base
Base class for MIME specializations.
email.mime.image
Class representing image/* type MIME documents.
email.mime.message
Class representing message/* MIME documents.
email.mime.multipart
Base class for MIME multipart/* type messages.
email.mime.nonmultipart
Base class for MIME type messages that are not multipart.
email.mime.text
Class representing text/* type MIME documents.
email.parser
Parse flat text email messages to produce a message object structure.
email.policy
Controlling the parsing and generating of messages
email.utils
Miscellaneous email package utilities.
json
Encode and decode the JSON format.
json.tool
A command-line interface to validate and pretty-print JSON.
mailbox
Manipulate mailboxes in various formats
mimetypes
Mapping of filename extensions to MIME types.
quopri
Encode and decode files using the MIME quoted-printable encoding.

Structured Markup Processing Tools

html
Helpers for manipulating HTML.
html.entities
Definitions of HTML general entities.
html.parser
A simple parser that can handle HTML and XHTML.
xml
Package containing XML processing modules
xml.dom
Document Object Model API for Python.
xml.dom.minidom
Minimal Document Object Model (DOM) implementation.
xml.dom.pulldom
Support for building partial DOM trees from SAX events.
xml.etree.ElementTree
Implementation of the ElementTree API.
xml.parsers.expat
An interface to the Expat non-validating XML parser.
xml.parsers.expat.errors
Constants used to describe error conditions.
xml.parsers.expat.model
Constants used to interpret content model information.
xml.sax
Package containing SAX2 base classes and convenience functions.
xml.sax.handler
Base classes for SAX event handlers.
xml.sax.saxutils
Convenience functions and classes for use with SAX.
xml.sax.xmlreader
Interface which SAX-compliant XML parsers must implement.

Internet Protocols and Support

ftplib
FTP protocol client (requires sockets).
http
HTTP status codes and messages
http.client
HTTP and HTTPS protocol client (requires sockets).
http.cookiejar
Classes for automatic handling of HTTP cookies.
http.cookies
Support for HTTP state management (cookies).
http.server
HTTP server and request handlers.
imaplib
IMAP4 protocol client (requires sockets).
ipaddress
IPv4/IPv6 manipulation library.
poplib
POP3 protocol client (requires sockets).
smtplib
SMTP protocol client (requires sockets).
socketserver
A framework for network servers.
urllib
urllib is a package that collects several modules for working with URLs:
urllib.error
Exception classes raised by urllib.request.
urllib.parse
Parse URLs into or assemble them from components.
urllib.request
Extensible library for opening URLs.
urllib.response
Response classes used by urllib.
urllib.robotparser
Load a robots.txt file and answer questions about fetchability of other URLs.
uuid
UUID objects (universally unique identifiers) according to RFC 9562
webbrowser
Easy-to-use controller for web browsers.
wsgiref
WSGI Utilities and Reference Implementation.
wsgiref.handlers
WSGI server/gateway base classes.
wsgiref.headers
WSGI response header tools.
wsgiref.simple_server
A simple WSGI HTTP server.
wsgiref.types
WSGI types for static type checking
wsgiref.util
WSGI environment utilities.
wsgiref.validate
WSGI conformance checker.
xmlrpc
Server and client modules implementing XML-RPC.
xmlrpc.client
XML-RPC client access.
xmlrpc.server
Basic XML-RPC server implementations.

Multimedia Services

colorsys
Conversion functions between RGB and other color systems.
wave
Provide an interface to the WAV sound format.

Internationalization

gettext
Multilingual internationalization services.
locale
Internationalization services.

Graphical user interfaces with Tk

_tkinter
A binary module that contains the low-level interface to Tcl/Tk.
idlelib
Implementation package for the IDLE shell/editor.
tkinter
Interface to Tcl/Tk for graphical user interfaces
tkinter.colorchooser
Color choosing dialog
tkinter.commondialog
Tkinter base class for dialogs
tkinter.dialog
A simple dialog box built on the classic Tk widgets.
tkinter.dnd
Tkinter drag-and-drop interface
tkinter.filedialog
Dialog classes for file selection
tkinter.font
Tkinter font-wrapping class
tkinter.messagebox
Various types of alert dialogs
tkinter.scrolledtext
Text widget with a vertical scroll bar.
tkinter.simpledialog
Simple dialog windows
tkinter.ttk
Tk themed widget set
turtle
An educational framework for simple graphics applications
turtledemo
A viewer for example turtle scripts

Development Tools

doctest
Test pieces of code within docstrings.
pydoc
Documentation generator and online help system.
test
Regression tests package containing the testing suite for Python.
test.regrtest
Drives the regression test suite.
test.support
Support for Python's regression test suite.
test.support.bytecode_helper
Support tools for testing correct bytecode generation.
test.support.import_helper
Support for import tests.
test.support.os_helper
Support for os tests.
test.support.script_helper
Support for Python's script execution tests.
test.support.socket_helper
Support for socket tests.
test.support.threading_helper
Support for threading tests.
test.support.warnings_helper
Support for warnings tests.
typing
Support for type hints (see :pep:`484`).
unittest
Unit testing framework for Python.
unittest.mock
Mock object library.

Debugging and profiling

bdb
Debugger framework.
faulthandler
Dump the Python traceback.
pdb
The Python debugger for interactive interpreters.
profiling
Python profiling tools for performance analysis.
profiling.sampling
Statistical sampling profiler for Python processes.
profiling.tracing
Deterministic tracing profiler for Python programs.
pstats
Statistics object for analyzing profiler output.
timeit
Measure the execution time of small code snippets.
trace
Trace or track Python statement execution.
tracemalloc
Trace memory allocations.

Software Packaging and Distribution

ensurepip
Bootstrapping the "pip" installer into an existing Python installation or virtual environment.
venv
Creation of virtual environments.
zipapp
Manage executable Python zip archives

Python Runtime Services

__future__
Future statement definitions
__main__
The environment where top-level code is run. Covers command-line interfaces, import-time behavior, and ``__name__ == '__main__'``.
abc
Abstract base classes according to :pep:`3119`.
annotationlib
Functionality for introspecting annotations
atexit
Register and execute cleanup functions.
builtins
The module that provides the built-in namespace.
contextlib
Utilities for with-statement contexts.
dataclasses
Generate special methods on user-defined classes.
gc
Interface to the cycle-detecting garbage collector.
inspect
Extract information and source code from live objects.
site
Module responsible for site-specific configuration.
sitecustomize
After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary site-specific customizations.
sys
Access system-specific parameters and functions.
sys.monitoring
Access and control event monitoring
sysconfig
Python's configuration information
traceback
Print or retrieve a stack traceback.
usercustomize
After this, an attempt is made to import a module named usercustomize, which can perform arbitrary user-specific customizations, if ENABLE_USER_SITE is true.
warnings
Issue warning messages and control their disposition.

Custom Python Interpreters

code
Facilities to implement read-eval-print loops.
codeop
Compile (possibly incomplete) Python code.

Importing Modules

importlib
The implementation of the import machinery.
importlib.abc
Abstract base classes related to import
importlib.machinery
Importers and path hooks
importlib.metadata
Accessing package metadata
importlib.resources
Package resource reading, opening, and access
importlib.resources.abc
Abstract base classes for resources
importlib.util
Utility code for importers
modulefinder
Find modules used by a script.
pkgutil
Utilities for the import system.
runpy
Locate and run Python modules without importing them first.
zipimport
Support for importing Python modules from ZIP archives.

Python Language Services

ast
Abstract Syntax Tree classes and manipulation.
compileall
Tools for byte-compiling all Python source files in a directory tree.
dis
Disassembler for Python bytecode.
keyword
Test whether a string is a keyword in Python.
pickletools
Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions.
py_compile
Generate byte-code files from Python source files.
pyclbr
Supports information extraction for a Python module browser.
symtable
Interface to the compiler's internal symbol tables.
tabnanny
Tool for detecting white space related problems in Python source files in a directory tree.
token
Constants representing terminal nodes of the parse tree.
tokenize
Lexical scanner for Python source code.

MS Windows Specific Services

msvcrt
Miscellaneous useful routines from the MS VC++ runtime.
winreg
Routines and objects for manipulating the Windows registry.
winsound
Access to the sound-playing machinery for Windows.

Unix-specific services

fcntl
The fcntl() and ioctl() system calls.
grp
The group database (getgrnam() and friends).
posix
The most common POSIX system calls (normally used via module os).
pty
Pseudo-Terminal Handling for Unix.
pwd
The password database (getpwnam() and friends).
resource
An interface to provide resource usage information on the current process.
shlex
Simple lexical analysis for Unix shell-like languages.
syslog
An interface to the Unix syslog library routines.
termios
POSIX style tty control.
tty
Utility functions that perform common terminal control operations.

Superseded modules

getopt
Portable parser for command line options; support both short and long option names.
profile
Pure Python profiler (deprecated).

Removed Modules

aifc
Removed in 3.13.
asynchat
Removed in 3.12.
asyncore
Removed in 3.12.
audioop
Removed in 3.13.
cgi
Removed in 3.13.
cgitb
Removed in 3.13.
chunk
Removed in 3.13.
crypt
Removed in 3.13.
distutils
Removed in 3.12.
imghdr
Removed in 3.13.
imp
Removed in 3.12.
mailcap
Removed in 3.13.
msilib
Removed in 3.13.
nis
Removed in 3.13.
nntplib
Removed in 3.13.
ossaudiodev
Removed in 3.13.
pipes
Removed in 3.13.
smtpd
Removed in 3.12.
sndhdr
Removed in 3.13.
spwd
Removed in 3.13.
sunau
Removed in 3.13.
telnetlib
Removed in 3.13.
uu
Removed in 3.13.
xdrlib
Removed in 3.13.