The names are only a convention. What counts is the single and double star.
The stars also work in the other direction, to unpack when calling:
numbers = [1, 2, 3]
print(*numbers) # same as print(1, 2, 3)
Common uses: decorators (pass everything through to the wrapped function), wrapper functions, and APIs that accept optional settings. Do not overuse them. Explicit parameters are easier to read and document.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
They let a function accept a variable number of arguments.
*argscollects extra positional arguments into a tuple.**kwargscollects extra keyword arguments into a dict.The names are only a convention. What counts is the single and double star.
The stars also work in the other direction, to unpack when calling:
Common uses: decorators (pass everything through to the wrapped function), wrapper functions, and APIs that accept optional settings. Do not overuse them. Explicit parameters are easier to read and document.