Python & FastAPI•Part 2: Python Core Language, Internals & Runtime (6 - 25)
`*args`, `**kwargs`, positional-only and keyword-only arguments:
In Simple Words:
*args: Collects positional arguments into a tuple.**kwargs: Collects keyword arguments into a dictionary./: Everything to the left is positional-only.*: Everything to the right is keyword-only.
python
def configure(host, port, /, timeout=30, *, secure=True):
return f"{host}:{port} (timeout={timeout}, secure={secure})"
# Valid:
configure("127.0.0.1", 8080, secure=True)
# Invalid (raises TypeError):
# configure(host="127.0.0.1", port=8080)