📒 Python glossary
57 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.
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-30Global 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.
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`.
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.
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.
Class
→ lesson-81A blueprint for objects. Created with `class Foo:`. Defines attributes + methods.
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`.
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, ...}`.
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.
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. Replaces setup.py + setup.cfg + (eventually) requirements.txt.
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.
JWT
→ fastapi-25JSON Web Token — a signed, base64-encoded payload used for stateless auth. 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.
Missing a term? Tell us what to add.