Python **kwargs
Arbitrary Keyword Arguments, **kwargs
If you do not know how many keyword arguments that will be passed into your function,
add two asterisk: **
before the parameter name in the function definition.
This way the function will receive a dictionary of arguments, and can access the items accordingly:
Example
If the number of keyword arguments is unknown, add a double
**
before the parameter name:
def my_function(**kid):
print("His last name is " + kid["lname"])
my_function(fname = "Tobias", lname = "Refsnes")
Try it Yourself »
print("His last name is " + kid["lname"])
my_function(fname = "Tobias", lname = "Refsnes")
Arbitrary Kword Arguments are often shortened to **kwargs in Python documentations.
Related Pages
Python Functions Tutorial Function Call a Function Function Arguments *args Keyword Arguments Default Parameter Value Passing a List as an Argument Function Return Value The pass Statement i Functions Function Recursion