You’ll be able to
- Accept variable numbers of positional args with
*args - Accept variable keyword args with
**kwargs - Unpack collections into function calls
- Design flexible function APIs
Loading lesson…
Why this matters
Decorators, functools.wraps, and framework hooks (Flask view functions, pytest fixtures) all rely on *args, **kwargs forwarding. Getting unpacking wrong is the #1 source of "missing 1 required positional argument" errors in wrapper code.
Common pitfalls
- Mixing positional and keyword unpacking order —
f(*args, **kwargs)must come after named params in the signature. - Passing a dict to
*argsinstead of**kwargs— you'll iterate keys silently, not values. - Forgetting
/and*markers for positional-only or keyword-only params — costs you API clarity in libraries.