Function Arguments
Positional and keyword arguments, default values, and the mutable default that catches everyone once.
Overview
Positional and keyword
def greet(name, greeting="Hello"):
greet("ana") matches by position: the first argument becomes name. greet("ana", greeting="Hi") names the second explicitly. Both reach the same function; the difference is what the call site tells a reader.
Keywords earn their place when the value alone is meaningless. send(msg, True) tells you nothing; send(msg, urgent=True) tells you everything. A boolean argument is almost always worth naming.
One rule: in a call, positional arguments come first. f(greeting="Hi", "ana") is a syntax error, because Python cannot tell where the positional one was meant to go.
arguments.py
mutable_default.py
Worth knowing
None and build it inside.