Functions, *args, **kwargs
Reusable blocks. *args collects positional args into a tuple; **kwargs collects keyword args into a dict.
Code example
def greet(name, greeting='Hello', **extras):
msg = f"{greeting}, {name}!"
if extras.get('shout'):
msg = msg.upper()
return msg
greet('Ada') # 'Hello, Ada!'
greet('Ada', greeting='Hi') # 'Hi, Ada!'
greet('Ada', greeting='Hi', shout=True) # 'HI, ADA!'
How it works
Functions are defined with `def` and return with `return` (None if no return statement). Default arguments are evaluated once at function-definition time — mutable defaults like `def f(x=[])` are a famous footgun. `*args` collects extra positional args into a tuple; `**kwargs` collects extra keyword args into a dict. FastAPI uses `**kwargs` heavily in route signatures — every query param, path param, and body becomes a kwarg.
🔍 Where this is used in OpenBenchML
Every route handler in app/routes/ is a function. FastAPI inspects the signature to decide what to inject.