π Python glossary
Python terms in plain English
Short, opinionated definitions. No jargon ladders, no "see also" loops. Each term links to a CodeMentor lesson that teaches it for real. Skim, search (Cmd+F), or read top to bottom.
Async & concurrency
async def
β sr-21Declares a coroutine. Can be awaited; runs cooperatively on an event loop.
asyncio.gather
β sr-25Run multiple coroutines concurrently and wait for all of them. The bread-and-butter of fan-out.
asyncio.TaskGroup
β sr-22Structured concurrency primitive (Python 3.11+). `async with TaskGroup()` ensures every spawned task is awaited and any exception cancels the whole group β safer than bare `gather`.
asyncio.wait_for
β sr-22Cap any awaitable with a timeout: `await asyncio.wait_for(coro, timeout=5)`. Raises `TimeoutError` on expiry and cancels the inner task. Essential for any external call.
await
β sr-22Pauses a coroutine until another coroutine/Future finishes. Only legal inside `async def`.
Event loop
β sr-23Scheduler that drives async code β runs ready coroutines, parks blocked ones. `asyncio.run(main())` starts one.
GIL
β sr-37Global Interpreter Lock β CPython's mutex that lets only one thread run Python bytecode at a time. Threads still help for I/O; for CPU, use processes. An optional free-threaded build (PEP 703, officially supported since 3.14) removes it.
Data structures
Dict comprehension
β lesson-67Same as list comp, but builds a dict: `{k: v for k, v in pairs}`.
Dictionary
β lesson-45Hash map from keys to values. Insertion order preserved since Python 3.7.
Generator
β lesson-110A function with `yield`. Produces values lazily, one at a time β uses constant memory for streams.
Iterable
β lesson-49Anything you can loop over with `for`. Lists, tuples, sets, dicts, strings, files, generators β all iterables.
List comprehension
β lesson-66Inline syntax for building a list from another iterable, with optional filter: `[f(x) for x in xs if cond(x)]`. Beats `map+filter+lambda`.
NamedTuple
β lesson-105Tuple with named fields β accessed by `t.x` instead of `t[0]`. `typing.NamedTuple` is the modern form; gives you type hints + immutability for free.
Set
β lesson-50Unordered collection of unique hashable values. O(1) membership check.
Tuple
β lesson-44Ordered immutable sequence. Use for fixed-size records and as dict keys.
Errors & control flow
Context manager
β lesson-108An object usable with `with`. Guarantees cleanup even on exception β `open()`, locks, DB sessions.
EAFP
β lesson-103βEasier to Ask Forgiveness than Permissionβ. Idiomatic Python: try the operation, catch the exception, rather than pre-checking.
Exception
β lesson-100An object that signals something went wrong. Raised with `raise`, caught with `try/except`.
try / except / finally
β lesson-101Handle exceptions. `finally` always runs (cleanup). Catching `Exception` is usually too broad β be specific.
Functions
*args, **kwargs
β lesson-65Capture variable positional and keyword arguments. Lets a function accept any signature.
Closure
β lesson-118An inner function that captures variables from its enclosing scope. The captured value is by reference, not by value.
Decorator
β lesson-115A higher-order function that wraps another to add behavior β logging, caching, auth. `@cache` is one.
Default argument
β lesson-60Parameter with a fallback value: `def f(x=10)`. Beware mutable defaults β `def f(xs=[])` is a classic trap.
Function
β lesson-58Named reusable block of code. Defined with `def`. First-class β you can pass functions like any other value.
functools.partial
β sr-108Pre-bind some arguments of a function β produces a new callable with fewer parameters. Cleaner than a wrapping lambda for currying-style use.
Lambda
β lesson-69An anonymous one-line function: `lambda x: x*2`. Use for short callbacks; prefer `def` when readable.
OOP
__init__
β lesson-84The constructor β runs when you call the class. Used to set instance attributes.
ABC (Abstract base class)
β lesson-145Inheriting `abc.ABC` + decorating with `@abstractmethod` prevents instantiation until subclasses override every abstract method. Documentation the language enforces.
Class
β lesson-81A blueprint for objects. Created with `class Foo:`. Defines attributes + methods.
classmethod / staticmethod
β lesson-82`@classmethod` receives the class as `cls` (alternative constructors, class-level state). `@staticmethod` gets neither `self` nor `cls` β a function namespaced inside the class.
Dataclass
β lesson-105Decorator (`@dataclass`) that auto-generates `__init__`, `__repr__`, and `__eq__` from typed attributes.
Dunder methods
β lesson-90Double-underscore methods that hook into Python syntax: `__add__`, `__len__`, `__repr__`. Make your objects feel native.
Inheritance
β lesson-88A class can inherit attributes and methods from a parent class: `class Dog(Animal):`.
Instance
β lesson-82A specific object built from a class. `dog = Dog()` makes one instance of `Dog`.
Property
β lesson-86`@property` turns a method into a read-only attribute. Accessed without parentheses; computed on demand. Common when the value derives from other state.
self
β lesson-83The current instance, passed implicitly as the first argument to methods. By convention named `self`, but the name isn't magic.
Standard library
collections.Counter
β lesson-128Dict subclass that counts hashable items: `Counter("hello")` β `{'l': 2, ...}`.
collections.defaultdict
β iv-43Dict that auto-creates missing keys with a factory: `defaultdict(list)` returns `[]` for any new key. Replaces `if k not in d: d[k] = []`-style code in counters and grouping.
dataclasses.field
β lesson-106Configure a dataclass attribute β mutable defaults, init/repr behavior. Use `field(default_factory=list)` to avoid the mutable-default trap.
functools.cache
β lesson-131Memoize a pure function with `@functools.cache`. Replaces hand-rolled dict caching.
itertools
β lesson-130Iterator building blocks β `chain`, `groupby`, `combinations`, `accumulate`. Lazy, memory-friendly.
pathlib.Path
β lesson-126Object-oriented filesystem paths. `Path(".").rglob("*.py")` beats `os.walk + os.path.join`.
Syntax
f-string
β lesson-08An f-prefixed string literal that lets you inline expressions: `f"x={x}"`. Introduced in Python 3.6, now the default formatter.
Match statement
β iv-94Structural pattern matching (PEP 634, Python 3.10+). `match val: case Point(x, y): ...`. Matches on shape, not just value β closer to Rust/Scala match than C switch.
Slicing
β lesson-31Substring/sublist via `s[start:stop:step]`. Negative indices count from the end.
Truthy / falsy
β lesson-21Values that act as True / False in `if` statements. Empty containers, `0`, `None`, `""` are falsy; everything else is truthy.
Type hints
β lesson-101Annotations that describe expected types: `def f(x: int) -> str:`. Not enforced at runtime β used by tools like mypy.
Walrus operator
β lesson-92`:=` assigns inside an expression. Useful when you'd otherwise compute the same value twice.
Testing
Coverage
β lesson-143Measures which lines your tests execute. 100% is rarely the goal β 'every important path covered once' is.
Fixture
β lesson-141Reusable test setup. Declared with `@pytest.fixture`, injected by parameter name.
Parametrize
β lesson-142Run the same test against multiple inputs: `@pytest.mark.parametrize("x,y", [(1,2), (3,4)])`. Replaces copy-paste tests.
pytest
β lesson-140De facto Python test framework. `def test_x():` and `assert` β that's the whole API.
Tooling
Black
β lesson-154Opinionated Python formatter. Stops bike-shedding about style β one command, one canonical form.
mypy
β lesson-156Static type checker for Python. Catches type errors before runtime. Works best when you adopt incrementally.
pip
β lesson-151Python's package manager. `pip install requests` fetches from PyPI.
pyproject.toml
β lesson-153Modern Python project config (PEP 518/621): metadata, dependencies and tool settings in one file. Replaces setup.py + setup.cfg; requirements.txt is still widely used for pinning exact versions.
requirements.txt
β lesson-152Plain text list of dependencies, optionally pinned: `requests==2.31.0`. `pip install -r requirements.txt` recreates the env.
ruff
β lesson-155Fast Rust-based Python linter. Replaces flake8 + isort + several plugins, ~100Γ faster.
uv
β lesson-157Fast Rust-based Python package + project manager. Drop-in replacement for pip + venv with much faster installs.
virtualenv / venv
β lesson-150Per-project Python environment. Isolates dependencies so two projects can use different package versions.
Web & APIs
CORS
β fastapi-30Cross-Origin Resource Sharing β browser security check on which origins may call your API. Set with response headers, not in the client.
FastAPI
β fastapi-01Modern Python web framework. Type-driven, async-first, autogenerates OpenAPI docs.
httpx ASGITransport
β fastapi-18Test transport that calls your FastAPI/Starlette app in-process β no real TCP, no port conflict, deterministic, 10-100Γ faster than spinning up a real server.
JWT
β fastapi-25JSON Web Token β a signed, base64url-encoded payload used for stateless auth. Signed, not encrypted: anyone can read the payload, so never put secrets in it. Verify, don't trust.
OpenAPI
β fastapi-12Spec for describing REST APIs as JSON/YAML. FastAPI emits one automatically; tools generate clients + docs from it.
Pydantic
β fastapi-05Data validation library. Define a model, get parsing + validation + JSON serialization for free.
REST
β fastapi-08Architectural style for HTTP APIs β resources at URLs, verbs in the HTTP method, stateless requests.
WSGI / ASGI
β fastapi-01Server-application interfaces. WSGI (PEP 3333) is sync β Flask, Django until 3.0. ASGI extends it for async + WebSockets β FastAPI, Starlette, modern Django. uvicorn / hypercorn speak ASGI; gunicorn speaks WSGI.
Missing a term? Tell us what to add.