Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
Python interview question
Functions & functional toolsJuniorVery commonPractical

What do `*args` and `**kwargs` mean in a function signature?

Answer

`*args` collects any extra positional arguments the caller passes beyond the named parameters into a tuple, and `**kwargs` collects any extra keyword arguments into a dict. The names `args` and `kwargs` are just convention, not syntax requirements — the meaningful part is the `*` and `**` prefixes. They let a function accept a flexible, variable number of arguments and are commonly used for wrapper functions and decorators that must forward whatever arguments they receive to another callable.

Strong answer includes

  • *args gathers extra positionals into a tuple
  • **kwargs gathers extra keywords into a dict
  • used to forward arbitrary arguments, e.g. in decorators

Practical example

Forward an arbitrary call signature
Python
editable · browser sandbox
Result
Run the code to see the result.

*args collects positional values into a tuple and **kwargs collects keyword values into a dict. Forwarding both lets the wrapper preserve the wrapped function's calling flexibility.

Expected result: The wrapper prints ('Ada',), then {'punctuation': '.'}, then Hello, Ada.

#functions#args-kwargs

Sources

The Python TutorialPython Software Foundation · Baseline syntax, control flow, functions and module basicsThe Python Language ReferencePython Software Foundation · Precise scoping, evaluation order and expression semantics