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
Top answer
1 of 10
417

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.

🌐
Trey Hunner
treyhunner.com › 2018 › 04 › keyword-arguments-in-python
Keyword (Named) Arguments in Python: How to Use Them
April 4, 2018 - When we use keyword/named arguments, it’s the name that matters, not the position: So unlike many other programming languages, Python knows the names of the arguments our function accepts.
🌐
W3Schools
w3schools.com › python › gloss_python_function_keyword_arguments.asp
Python Keyword Arguments
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... You can also send arguments with the key = value syntax.
🌐
Thomas Stringer
trstringer.com › python-named-arguments
Why You Should Typically Use Named Arguments in Python | Thomas Stringer
December 27, 2020 - If you call this function my_function(1, 2) with positional arguments, then a is 1 and b is 2. ... Now with the existing invocation my_function(1, 2), a is still 1 but it’s now c that is set to 2. This is unlikely the desired transition from signature to invocation. The function signature has changed, but if the function invocation doesn’t know about that it could introduce undesired behavior. If we had been calling this function with named parameters, then the signature change doesn’t affect the args passed in.
🌐
Reddit
reddit.com › r/python › do you find named arguments beneficial?
r/Python on Reddit: Do you find named arguments beneficial?
February 15, 2019 -

I have a background in Java, so the IDE (Eclipse) will tell you what a method or constructor requires as you're writing it, and if you use proper variable names, it shouldn't be hard to read even if you have a long list of parameters.

While I was aware of named arguments in Python, I never saw a reason to use them, until today, when I was looking at an example, and the code used named arguments, and it made it easier to understand.

Do you find named arguments clean and easy to read or is it just noise?

class GameWeapon(ABC):

def __init__(self, name, required_strength, damage):
 self._name = name
 self._required_strength = required_strength
 self._damage = damage

class ChargeGun(GameWeapon):

def __init__(self, name, required_strength, damage):
 super().__init__(name=name, required_strength=required_strength, damage=damage)

To me, the more I use it, the more I like it, especially if the class you're inheriting from isn't in the same directory.

🌐
Python.org
discuss.python.org › python help
Named arguments in CLI application - Python Help - Discussions on Python.org
June 10, 2024 - I’m writing a command line application, and have been reading up on best practices. In particular, I’ve come across these two recommendations, which are giving me some trouble: “If you’ve got two or more arguments for different things, you’re probably doing something wrong.”[1] “abusing flags to implement named arguments is the wrong thing to do unless all of the arguments are optional.”[2] My application flashes firmware to embedded devices over a serial connection.
Find elsewhere
🌐
Python
peps.python.org › pep-0736
PEP 736 – Shorthand syntax for keyword arguments at invocation | peps.python.org
A teacher may explain this feature to new Python programmers as, “where you see an argument followed only by an equals sign, such as f(x=), this represents a keyword argument where the name of the argument and its value are the same.
🌐
W3Schools
w3schools.com › python › python_arguments.asp
Python Function Arguments
An argument is the actual value that is sent to the function when it is called. def my_function(name): # name is a parameter print("Hello", name) my_function("Emil") # "Emil" is an argument
🌐
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 you pass values decides how they will be received by the function. The two most common ways are: ... Both methods are useful, but they behave differently. Keyword arguments mean you pass values by parameter names ...
🌐
Python.org
discuss.python.org › ideas
Syntactic sugar to encourage use of named arguments - Ideas - Discussions on Python.org
October 14, 2023 - Issue Named arguments confer many benefits by promoting explicit is better than implicit, thus increasing readability and minimising the risk of inadvertent transposition. However, the syntax can become needlessly repetitive and verbose. Consider the following call: my_function( my_first_variable=my_first_variable, my_second_variable=my_second_variable, my_third_variable=my_third_variable, ) The verbosity and redundancy discourages use of named arguments (and therefore, their benefits)...
🌐
UC Berkeley Statistics
stat.berkeley.edu › ~spector › extension › python › notes › node66.html
Named Arguments and Default Values
When you call a function, you can precede some or all of the arguments by a name and an equal sign, to let the function know exactly which argument you are passing to the function. So if we invoke the count_letter function as · num = count_letter(letter='a',string='dead parrot') we will get ...
🌐
Educative
educative.io › blog › what-are-keyword-arguments-in-python
What are keyword arguments in Python?
August 18, 2025 - Keyword arguments in Python let you pass values to functions by explicitly naming the parameters, improving code readability and flexibility.
🌐
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 - This works perfectly fine. Since you’re using these arguments as named arguments, you no longer need to stick to the same order that’s used in the function definition. Python no longer uses the position to assign the arguments to the parameters.
🌐
Python
docs.python.org › 3 › library › argparse.html
argparse — Parser for command-line options, arguments and subcommands
Create a new ArgumentParser object. All parameters should be passed as keyword arguments. Each parameter has its own more detailed description below, but in short they are: prog - The name of the program (default: generated from the __main__ module attributes and sys.argv[0])
🌐
Hexlet
hexlet.io › courses › python-functions › lessons › keyword-arguments › theory_unit
Named arguments | Python: Functions
Named arguments / Python: Functions: Introducing named arguments in addition to positional arguments
🌐
GeeksforGeeks
geeksforgeeks.org › python › args-kwargs-python
*args and **kwargs in Python - GeeksforGeeks
This is useful when you want your function to accept flexible, named inputs. Below example shows how **kwargs stores arguments in a dictionary. ... def fun(**kwargs): for k, val in kwargs.items(): print(k, "=", val) fun(s1='Python', s2='is', s3='Awesome')
Published   September 20, 2025
🌐
YouTube
youtube.com › watch
Python keyword arguments 🔑 - YouTube
python keyword arguments tutorial example explained#python #keyword #arguments# keyword arguments = arguments preceded by an identifier when we pass # ...
Published   December 7, 2020
🌐
YouTube
youtube.com › watch
Idiomatic Python: Named Arguments - YouTube
Continuing with how to write more Pythonic code, we look at using named arguments when calling functions (callables in general). I also make the case for def...
Published   December 1, 2023
🌐
DevCamp
devcamp.com › trails › introduction-programming-python › campsites › python-methods-functions › guides › overview-keyword-arguments-python-functions
Overview of Keyword Arguments in Python Functions
I think this is a logical approach because if you think about it a keyword argument needs to have a set of keys and associated values which as you know is the very definition of a dictionary and so that is one of the key elements to remember. Now let's take this and extend it out a little bit. So now if I call greeting and I pass in some named arguments so I could say first_name like this and then pass in Kristine and then I can say last_name equals Hudgens.
🌐
Python Morsels
pythonmorsels.com › accepting-arbitrary-keyword-arguments
Accepting arbitrary keyword arguments in Python - Python Morsels
December 4, 2020 - So this new function should accept our name argument and any keyword arguments given to it.