Glossary
A quick-reference glossary of jargon you will run into throughout the Python docs on this site — from everyday terms like module to implementation details like the GIL. Definitions are kept short on purpose; follow the related tutorial pages for the full story.
Term | Definition |
|---|---|
Bytecode | The low-level instructions the Python interpreter actually executes. Source code is compiled to bytecode (stored in |
Closure | A function that remembers values from the scope it was defined in, even after that scope has finished executing. Common in decorators and factory functions. |
Comprehension | A compact expression for building a list, dict, set, or generator from an iterable in a single line, optionally with a filter. |
Context manager | An object that defines |
Decorator | A function that wraps another function (or class) to add behaviour without changing its source code, applied with the |
Docstring | A string literal placed as the first statement in a module, function, class, or method, used as that object's documentation and accessible via |
Duck typing | A style of typing where an object's suitability is determined by the methods and attributes it has, not its actual class — "if it walks like a duck...". |
Exception | An event raised when an error occurs during execution, which interrupts the normal flow of a program unless it is caught with try/except. |
First-class function | A function that can be assigned to a variable, passed as an argument, or returned from another function, just like any other value. |
f-string | A string literal prefixed with |
Garbage collection | Python's automatic memory management, which reclaims objects that are no longer reachable — primarily via reference counting, with a cyclic collector for reference cycles. |
Generator | A function containing |
GIL | The Global Interpreter Lock — a mutex in CPython that allows only one thread to execute Python bytecode at a time, which limits true parallelism for CPU-bound threads. |
Higher-order function | A function that takes another function as an argument, returns a function, or both — for example |
Immutable | An object whose state cannot be changed after it is created. Numbers, strings, and tuples are immutable — any "change" actually creates a new object. |
Interpreter | The program that reads and executes Python source code (compiling it to bytecode first), as opposed to a compiler that produces a standalone binary ahead of time. |
Iterable | Any object you can loop over with |
Iterator | An object that produces values one at a time via |
Magic method / dunder method | A method with double underscores on each side (like |
Metaclass | The "class of a class" — by default |
Module | A single Python file containing definitions and statements that can be imported and reused in other files. |
Monkey patching | Modifying or extending a class or module at runtime, after it has already been defined — for example, replacing a method on a third-party class for testing. |
Mutable | An object whose contents can be changed in place after creation, without creating a new object. Lists, dicts, and sets are mutable. |
Namespace | A mapping from names to objects (roughly a dictionary) that determines which variables and functions are visible at a given point in code. |
Package | A directory of Python modules that contains an |
PEP | A Python Enhancement Proposal — a design document that describes a new feature or process for the language. PEP 8, the style guide, is the most widely referenced. |
REPL | The Read-Eval-Print Loop — the interactive Python shell you get by running |
Scope | The region of code where a name is visible and accessible — Python resolves names using the LEGB rule: Local, Enclosing, Global, Built-in. |
Slice | A way to extract a subsequence from a sequence using |
Truthy/Falsy | Whether a value evaluates as |
Type hint | Optional annotation that documents the expected type of a variable, parameter, or return value (e.g. |
Virtual environment | An isolated Python environment with its own installed packages, created with |