Define abstract base classes in Python with ABCMeta, @abstractmethod, and virtual subclass registration.
Reference
Modules
Popular standard-library modules and how to use them.
- abc module
- argparse
The standard library module for parsing command-line arguments, defining program usage, and generating help messages.
- ast
The ast module provides classes for parsing, analyzing, and manipulating Python source code as Abstract Syntax Trees
- asyncio
The asyncio module provides infrastructure for writing concurrent code using async/await syntax in Python
- atexit module
The atexit module registers functions to run when the Python interpreter exits normally. Covers register(), unregister(), LIFO order, and limitations.
- base64
The base64 module provides functions for encoding and decoding binary data to and from ASCII text format
- bisect
Binary search and sorted insertion helpers for maintaining ordered lists in Python's standard library.
- calendar
The calendar module provides functions for working with calendars, including printing text calendars and date calculations
- collections
Specialized container datatypes that extend Python's built-in containers for efficient data handling.
- concurrent.futures
High-level interface for asynchronously executing callables using threads or processes
- configparser
The configparser module provides ConfigParser for reading and writing configuration files in INI format
- contextlib
Utilities for context managers: contextmanager, suppress, nullcontext, closing, ExitStack, and redirect functions
- copy
The copy module provides functions for creating shallow and deep copies of Python objects
- cProfile module
Profile Python code to find performance bottlenecks using the cProfile module.
- csv
The csv module provides tools for reading and writing CSV files — reader, writer, and DictReader/DictWriter classes.
- dataclasses
The dataclasses module provides a decorator and functions for automatically adding __init__ and __repr__ to user-defined classes
- datetime
The datetime module provides datetime, date, time, timedelta, and timezone classes for working with dates and times in Python
- decimal
The decimal module provides precise fixed-point and floating-point arithmetic with exact decimal representation, configurable precision, and rounding modes
- difflib
The difflib module provides tools for comparing sequences and generating differences in various formats
- dis module
The dis module disassembles Python bytecode, exposing what CPython actually runs. Covers dis(), Bytecode, Instruction objects, and bytecode analysis.
- email module
Parse, construct, and manipulate email messages. Build MIME messages, handle encoding, and work with email addresses using Python's standard library.
- enum
The enum module provides support for enumerations — named constants grouped into classes with useful methods
- fractions
The fractions module provides support for rational number arithmetic using the Fraction class
- functools
Higher-order functions and operations on callable objects including caching, partial application, and function composition
- gc module
The gc module provides interfaces to Python's garbage collector for debugging memory issues and controlling collection behavior.
- glob
The glob module provides Unix-style pathname pattern expansion for finding files matching wildcards like *, ?, and character ranges
- gzip
The gzip module provides functions and classes for reading and writing gzip-compressed files, modeled after the GNU gzip utilities
- hashlib
The hashlib module provides cryptographic hash functions for secure password storage, data integrity verification, and digital signatures
- heapq
The heapq module provides functions for working with heaps (priority queues), including push, pop, and merge operations
- html
The html module provides utilities for escaping HTML special characters and parsing HTML/XHTML documents
- http
The http module provides classes for building HTTP clients and servers, including http.client for making requests and http.server for creating HTTP servers.
- inspect
Functions for introspecting live objects—modules, classes, functions, tracebacks, frames, and code objects
- io module
Core tools for working with text and binary I/O streams in Python.
- ipaddress
Work with IPv4 and IPv6 addresses, networks, and interfaces in Python
- itertools
Functions for working with iterators, including infinite generators, combinatorics, and iteration adapters.
- json
The json module provides functions for encoding and decoding JSON data in Python
- logging
The built-in logging module provides a flexible framework for emitting log messages from Python programs
- lzma module
Compress and decompress data with LZMA compression in Python. Use LZMAFile for files, compress/decompress for raw bytes, and tune preset levels.
- math
The math module provides mathematical functions for floating-point and integer operations
- mimetypes module
Map filenames to MIME types and back using the Python mimetypes module — covering guess_type, guess_extension, add_type, and the MimeTypes class.
- multiprocessing
The multiprocessing module provides process-based parallelism in Python, enabling concurrent execution by spawning separate processes to bypass the GIL
- operator
The operator module provides functional equivalents to Python's operators, useful for passing operators as arguments to higher-order functions
- os module
The os module provides a portable way of using operating system dependent functionality like files, directories, processes, and environment variables.
- os.path
The os.path module provides functions for manipulating file paths across different operating systems
- pathlib
The standard library module for object-oriented filesystem path manipulation, providing classes for working with files and directories
- pdb module
The Python debugger. Set breakpoints, step through code, inspect variables, and diagnose crashes interactively.
- pickle
The pickle module provides functions for serializing and deserializing Python objects to binary format
- platform
The platform module provides access to underlying platform identifying data such as OS name, version, machine type, and Python version information
- pprint
The pprint module provides pretty-printing capabilities for displaying Python data structures in a readable, formatted output
- queue
The standard library queue module provides thread-safe FIFO, LIFO, and priority queues for multi-threaded programming.
- random
The random module generates pseudo-random numbers and provides functions for random selection and sampling
- re module
The re module provides regular expression operations for pattern matching, searching, and text manipulation
- sched module
Schedule callable objects to run at specific times using the sched module — covering enter, enterabs, cancel, run, and the timefunc/delayfunc interface.
- selectors module
High-level I/O multiplexing in Python. Monitor multiple sockets or files for readiness using selectors — event-driven networking made simple.
- shelve module
Persist Python objects to a disk-based dictionary with the shelve module. Open, write, read, and manage shelf files with pickle-backed storage.
- shutil
The standard library module for high-level file operations including copying, moving, removing, and archiving files and directories.
- signal
The signal module provides mechanisms for handling asynchronous events in Python, letting you register handlers that run when specific signals arrive.
- smtplib module
Send emails from Python using SMTP. Connect to mail servers, authenticate, and send text or HTML messages with attachments via smtplib.
- socket
The standard library module for low-level network communication, providing access to BSD socket interfaces for creating network clients and servers.
- sqlite3
The sqlite3 module provides a lightweight disk-based database that doesn't require a separate server process, implementing the DB-API 2.0 specification
- statistics
The statistics module provides functions for calculating mathematical statistics like mean, median, mode, variance, and standard deviation
- string
A comprehensive reference for Python's string module covering common string constants, functions, and the Formatter class
- struct
The struct module converts between Python values and C structs packed into bytes, useful for binary file formats and network protocols
- subprocess
The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes
- sys
The sys module provides access to system-specific parameters and functions, including command-line arguments, the Python interpreter, and platform information
- tarfile
The tarfile module provides tools for reading and writing tar archives, including compressed formats like gzip, bzip2, and xz
- tempfile
The tempfile module provides functions for creating temporary files and directories securely in Python.
- textwrap
Python's textwrap module formats plain text by wrapping, dedenting, and shortening paragraphs.
- threading
The threading module provides thread-based parallelism for CPU-bound tasks and I/O-bound concurrency in Python.
- time
Python's time module provides functions for working with time, measuring performance, and handling delays.
- timeit
The timeit module provides a simple way to time small bits of Python code with high precision, minimizing overhead from measurement.
- tomllib module
Parse TOML files and strings with Python's built-in tomllib module. Added in Python 3.11.
- traceback
Extract, format, and print Python stack traces for debugging and error handling
- types module
Dynamic type creation utilities and type constants for built-in interpreter types, including FunctionType, GeneratorType, ModuleType, SimpleNamespace, and more.
- typing
Support for type hints, including generics, protocols, and utility types for annotating Python code
- unittest
The unittest module provides a unit testing framework for Python, supporting test fixtures, assertions, and test runners
- unittest.mock module
Create mock objects for tests. Replace real objects, fake their behavior, and assert how they were called.
- urllib.parse
The urllib.parse module provides functions for parsing and manipulating URLs and query strings
- uuid
Generate and work with universally unique identifiers (UUIDs) according to RFC 9562
- warnings
The warnings module provides control over warning messages issued by Python, allowing suppression, filtering, and conversion to exceptions
- weakref
Python's weakref module provides weak references to objects, allowing references that don't prevent garbage collection when all other references are gone.
- zipfile
The zipfile module provides tools for reading and writing ZIP archives, including support for compressed files and archive members
- zoneinfo
The zoneinfo module provides support for IANA time zones in Python, enabling accurate timezone handling for datetime objects