WBF Academy
Functional Beginner 2 min read

*args and **kwargs

Accept any number of positional or keyword arguments

Python Academy

Python Academy

Python Engineer

1 month ago

`*args` collects extra positional arguments into a tuple, and `**kwargs` collects extra keyword arguments into a dict. Together they let you write highly flexible APIs and decorator wrappers that transparently forward arguments. The names `args` and `kwargs` are only convention — what matters is the `*` and `**` prefix. Prefer explicit parameters when the caller interface is well-defined; reach for `*args`/`**kwargs` when you genuinely need variadic flexibility.

#python #args #kwargs #functions