Functions, arguments, and closures
Functions, arguments, and closures
A Python function is an object. It has a name, a docstring, a signature you can inspect, and it can be stored in a dict, passed to another function, or returned from one. That last property is why so much of the tooling in this course works the way it does. FastAPI routes are functions handed to a decorator. Agent tools are functions the SDK reads the signature of. A tool registry is a dict from string to function. None of that is special; it is functions being values.
The calling convention is the other thing to learn properly. Python lets you pass arguments by position or by name, give parameters defaults, collect extra arguments, and force callers to use keywords. Each of those is a small feature, but together they are how library APIs stay readable, and you will use them in your own Relay code from this lesson on.
Continue reading
Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.