Python · Functions

*args / **kwargs

Collects extra positional arguments into a tuple and extra keyword arguments into a dictionary.

Syntax
def f(*args, **kwargs):

Example

Open in the lab

Notes

The names args and kwargs are conventions; the star is what matters.

More in this group

def Default argument Docstring Function as value Keyword-only arguments lambda map() / filter() return

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course