Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
In a definition, *args collects extra positional arguments into a tuple and **kwargs collects extra keyword arguments into a dict; in a call, * and ** unpack a sequence or a mapping into arguments.
def f(*args, **kwargs) lets a function accept any number of positional and keyword arguments, which is common in wrappers and decorators that forward arguments to another function. Inside, args is a tuple and kwargs is a dict. At a call site, f(*items) spreads a list or tuple into positional arguments and f(**options) spreads a dict into keyword arguments. Parameters after *args become keyword-only, and a bare * does the same without collecting extras, while / marks positional-only parameters.