There are two related concepts, both called "keyword arguments".

On the calling side, which is what other commenters have mentioned, you have the ability to specify some function arguments by name. You have to mention them after all of the arguments without names (positional arguments), and there must be default values for any parameters which were not mentioned at all.

The other concept is on the function definition side: you can define a function that takes parameters by name -- and you don't even have to specify what those names are. These are pure keyword arguments, and can't be passed positionally. The syntax is

def my_function(arg1, arg2, **kwargs)

Any keyword arguments you pass into this function will be placed into a dictionary named kwargs. You can examine the keys of this dictionary at run-time, like this:

def my_function(**kwargs):
    print str(kwargs)

my_function(a=12, b="abc")

{'a': 12, 'b': 'abc'}
Answer from Ian Clelland on Stack Overflow
🌐
W3Schools
w3schools.com › python › gloss_python_function_keyword_arguments.asp
Python Keyword Arguments
The phrase Keyword Arguments are often shortened to kwargs in Python documentations.
🌐
GeeksforGeeks
geeksforgeeks.org › python › keyword-and-positional-argument-in-python
Keyword and Positional Argument in Python - GeeksforGeeks
September 18, 2025 - When calling a function, the way ... useful, but they behave differently. Keyword arguments mean you pass values by parameter names while calling the function....
Discussions

python - Normal arguments vs. keyword arguments - Stack Overflow
How are "keyword arguments" different from regular arguments? Can't all arguments be passed as name=value instead of using positional syntax? ... You might also want to read PEP 3102 -- they're tidying up some of this stuff in Python 3. More on stackoverflow.com
🌐 stackoverflow.com
Keyword argument or positional argument?
Keyword argument or positional argument · I guess ‘start’ and ‘stop’ are positional arguments, but what are the rest arguments? Are they positonal or keyword · They are both–you have the option to use keywords but if you write np.linspace(0, 1, 100, False) those will be interpreted ... More on discuss.python.org
🌐 discuss.python.org
5
0
January 15, 2024
Positional Arguments or Keyword Arguments - What is the best practice?
TLDR; * args don’t need a name and the result is a tuple of values. **kwargs results in a dict of key/value pairs of argument and value (respectively). When defining a function you can also use a positional argument Python supports 5 types of arguments for a function: Positional arguments. Keyword arguments. Any number of positional arguments (* args) Any number of keyword arguments (**kwargs) Default arguments. It’s very common for beginners to get the order wrong when defining a function it’s an easy enough error to spot. (Note there is no space between the * and args - it was changing markup in my post) By the way there is no need to use the explicit names “args” and “kwargs,” but they are commonly used for readability. you can name them whatever, it’s the leading asterisk and double asterisk that count. More on reddit.com
🌐 r/Python
8
4
February 27, 2022
I tried creating a second database in flask-sqlalchemy for pytesting database and it doesn't seem to be working. Here is the error. " E TypeError: SQLAlchemy.create_all() got an unexpected keyword argument 'bind_key' ". Can someone help fix this?
From where do you import SQLAlchemy ? More on reddit.com
🌐 r/flask
7
1
March 13, 2023
🌐
Trey Hunner
treyhunner.com › 2018 › 04 › keyword-arguments-in-python
Keyword (Named) Arguments in Python: How to Use Them
April 4, 2018 - Python has a number of functions that take an unlimited number of positional arguments. These functions sometimes have arguments that can be provided to customize their functionality. Those arguments must be provided as named arguments to distinguish them from the unlimited positional arguments. The built-in print function accepts the optional sep, end, file, and flush attributes as keyword-only arguments:
🌐
OpenStax
openstax.org › books › introduction-python-programming › pages › 6-6-keyword-arguments
6.6 Keyword arguments - Introduction to Python Programming | OpenStax
March 13, 2024 - So far, functions have been called using positional arguments, which are arguments that are assigned to parameters in order. Python also allows keyword arguments, which are arguments that use parameter names to assign values rather than order.
Top answer
1 of 10
416

There are two related concepts, both called "keyword arguments".

On the calling side, which is what other commenters have mentioned, you have the ability to specify some function arguments by name. You have to mention them after all of the arguments without names (positional arguments), and there must be default values for any parameters which were not mentioned at all.

The other concept is on the function definition side: you can define a function that takes parameters by name -- and you don't even have to specify what those names are. These are pure keyword arguments, and can't be passed positionally. The syntax is

def my_function(arg1, arg2, **kwargs)

Any keyword arguments you pass into this function will be placed into a dictionary named kwargs. You can examine the keys of this dictionary at run-time, like this:

def my_function(**kwargs):
    print str(kwargs)

my_function(a=12, b="abc")

{'a': 12, 'b': 'abc'}
2 of 10
224

There is one last language feature where the distinction is important. Consider the following function:

def foo(*positional, **keywords):
    print "Positional:", positional
    print "Keywords:", keywords

The *positional argument will store all of the positional arguments passed to foo(), with no limit to how many you can provide.

>>> foo('one', 'two', 'three')
Positional: ('one', 'two', 'three')
Keywords: {}

The **keywords argument will store any keyword arguments:

>>> foo(a='one', b='two', c='three')
Positional: ()
Keywords: {'a': 'one', 'c': 'three', 'b': 'two'}

And of course, you can use both at the same time:

>>> foo('one','two',c='three',d='four')
Positional: ('one', 'two')
Keywords: {'c': 'three', 'd': 'four'}

These features are rarely used, but occasionally they are very useful, and it's important to know which arguments are positional or keywords.

🌐
Tutorialspoint
tutorialspoint.com › python › python_keyword_arguments.htm
Python - Keyword Arguments
Python allows to pass function arguments in the form of keywords which are also called named arguments. Variables in the function definition are used as keywords. When the function is called, you can explicitly mention the name and its value.
🌐
Educative
educative.io › blog › what-are-keyword-arguments-in-python
What are keyword arguments in Python?
Keyword arguments in Python let you pass values to functions by explicitly naming the parameters, improving code readability and flexibility.
Find elsewhere
🌐
Python
peps.python.org › pep-3102
PEP 3102 – Keyword-Only Arguments | peps.python.org
In particular, it enables the declaration of “keyword-only” arguments: arguments that can only be supplied by keyword and which will never be automatically filled in by a positional argument.
🌐
Python Tutorial
pythontutorial.net › home › python basics › python keyword arguments
Python Keyword Arguments
October 13, 2020 - By using the keyword argument syntax, you don’t need to specify the arguments in the same order as defined in the function.
🌐
Python.org
discuss.python.org › python help
Keyword argument or positional argument? - Python Help - Discussions on Python.org
January 15, 2024 - Keyword argument or positional argument · I guess ‘start’ and ‘stop’ are positional arguments, but what are the rest arguments? Are they positonal or keyword · They are both–you have the option to use keywords but if you write np.linspace(0, 1, 100, False) those will be interpreted ...
🌐
Python
docs.python.org › 3 › glossary.html
Glossary — Python 3.14.8 documentation
keyword argument: an argument preceded by an identifier (e.g. name=) in a function call or passed as a value in a dictionary preceded by **. For example, 3 and 5 are both keyword arguments in the following calls to complex():
🌐
Reddit
reddit.com › r/python › positional arguments or keyword arguments - what is the best practice?
r/Python on Reddit: Positional Arguments or Keyword Arguments - What is the best practice?
February 27, 2022 -

Yesterday, I was going through the O Reilly book on Python and was trying to understand more about Functional programming. usually, I just pass positional arguments(instinctively). I hardly try to use keyword arguments or kwargs.

Apparently, in other languages like C or C++, you have to pass arguments in a particular order. But in Python, you can overcome this by using keyword arguments.

def my_func(a, b, c):

return a + b + c

print(my_func(a=4, c=2, b=5))

Here, we are able to change the order of our arguments by using keyword arguments.

The thing to be careful in Python is when you mix positional and keyword arguments.

def my_func(a, b, c):

return a + b + c

print(my_func(4, c=2, 5))

You cannot do the above! Python will not explicitly assume that 5 refers to b. Once you start using keyword arguments, you cannot use positional arguments anymore. So you have to write like this.

def my_func(a, b, c):

return a + b + c

print(my_func(4, c=2, b=5))

I wrote my learning about different types of arguments like - positional, *args and **kwargs in my blog. Please check it out if you would like to read it.

🌐
Altcademy
altcademy.com › blog › what-is-a-keyword-argument-in-python
What is a keyword argument in Python - Altcademy.com
February 17, 2024 - In this case, coffee_type has a ... allows you to create keyword-only arguments. These are arguments that can only be specified using keywords and not positionally....
🌐
The Python Coding Book
thepythoncodingbook.com › home › blog › using positional arguments and named or keyword arguments in python functions [intermediate python functions series #2]
Positional arguments and keyword (named) arguments in Python functions
January 18, 2023 - Named (keyword) arguments include the parameter name followed by an equals = before the argument in the function call · Next Article: Optional Arguments With Default Values in Python Functions
🌐
GeeksforGeeks
geeksforgeeks.org › args-kwargs-python
*args and **kwargs in Python - GeeksforGeeks
A keyword argument is where you provide a name to the variable as you pass it into the function.
Published: December 11, 2024
🌐
GUVI
guvi.in › hub › python › keyword-arguments-in-python
Keyword Arguments in Python
In Python, Keyword Arguments is a special method that allows you to specify the name of the argument when you call a function, along with its value.
🌐
Runestone Academy
runestone.academy › ns › books › published › fopp › AdvancedFunctions › KeywordParameters.html
15.2. Keyword Parameters — Foundations of Python Programming
With keyword arguments, some of the values can be of the form paramname = <expr> instead of just <expr>. Note that when you have paramname = <expr> in a function definition, it is defining the default value for a parameter when no value is provided in the invocation; when you have paramname = <expr> in the invocation, it is supplying a value, overriding the default for that paramname.
🌐
SkillVertex
skillvertex.com › blog › python-keyword-arguments
Python - Keyword Arguments
March 19, 2024 - Keyword arguments in Python allow you to pass values to a function by explicitly specifying the parameter names.
🌐
Real Python
realpython.com › ref › glossary › kwargs
kwargs (keyword arguments) | Python Glossary – Real Python
In Python, **kwargs is a special syntax for defining functions that accept an undetermined number of keyword arguments.
🌐
Profound Academy
profound.academy › python-mid › positional-and-keyword-arguments-5LvKxDSUICCBH7Z96b1n
Positional and Keyword Arguments • Intermediate Python
January 17, 2025 - If we reverse the order of the arguments, we'll see different results: print(full_name('Brown', 'Anna')) # Prints 'Brown Anna' In contrast, keyword arguments enable us to specify the argument's name when we pass it to the function, thus enhancing ...