🌐
GUVI
guvi.in › blog › programming languages › python * single and **double asterisk explained!
Python * Single And **Double Asterisk Explained!
April 15, 2021 - Say, a beginner or someone who just switched from some other programming language to Python could end up scratching their heads about it. Single Asterisk (*) and Double Asterisk (**) used with function arguments are our topics for today. In this guide, we will talk about “What does * (single asterisk) and ** (double asterisk) do to parameters” with proper illustrations.
🌐
Medium
gaurav-patil21.medium.com › use-of-double-asterisk-in-python-962e83b63768
Use of double asterisk (**) in python - Gaurav Patil - Medium
March 4, 2022 - Use of double asterisk (**) in python Introduction : Double asterisk (**) is used for packing/unpacking a dictionary. Flexibility provided by ** is that we can unpack or pack dictionary of any number …
🌐
Quora
quora.com › What-do-two-asterisks-mean-in-Python
What do two asterisks mean in Python? - Quora
Answer (1 of 2): The double asterisk introduces the name of the dictionary that contains the keyword parameters passed to a function. The declaration: [code]def funct(pos_arg1, *args, **kw): [/code]indicates that if I call [code ]funct(1, 3, ...
🌐
YouTube
youtube.com › watch
Python: What does ** (double star/asterisk) and * (star/asterisk) for parameters? | *args & **kwargs - YouTube
The *args and **kwargs is a common idiom to allow arbitrary number of arguments to functions as described in the section more on defining functions in the Py...
Published   September 15, 2021
🌐
Medium
medium.com › @mo.sob7y111 › what-does-double-star-and-star-do-for-parameters-in-python-591ebe186c97
What does ** (double star) and * (star) do for parameters in Python? | by Mohamed Sobhi | Medium
July 12, 2022 - The double asterisk operator provides a shortcut method of what the power function provides by calculating the exponent of a base number to its power.
🌐
Sololearn
sololearn.com › en › Discuss › 1607822 › whats-the-difference-between-qp-and-qp-why-is-there-2-asterisks
What's the difference between *q=&p and **q=&p? Why is there 2 asterisks? | Sololearn: Learn to code for FREE!
December 2, 2018 - EDIT: pls see also Bennett Post ... address stored in the contents of memory address q. Two asterisks mean the variable is a pointer to a pointer....
🌐
OpenTeams
openteams.com › home › blog: inference & signals › blogs › what are python asterisk and slash special parameters for?
What Are Python Asterisk and Slash Special Parameters For? | OpenTeams: Open SaaS AI Solutions | Own Your Future with Open Source
December 3, 2024 - Whenever you think of Python’s asterisk operator (*), you most likely think of multiplication or exponentiation. Similarly, you probably associate the forward slash operator (/) with division.
🌐
TutorialsPoint
tutorialspoint.com › what-does-the-double-star-operator-mean-in-python
What does the Double Star operator mean in Python?
September 9, 2023 - At the time of defining a function the double asterisk(**) is used to create a Python function with an arbitrary number of keyword arguments.
Find elsewhere
🌐
Enterprise DNA
blog.enterprisedna.co › what-does-double-star-mean-in-python
https://blog.enterprisedna.co/what-does-double-sta...
In Python arithmetic, the double asterisks represent exponentiation, which is a type of arithmetic operation. It allows you to raise a number to the power of another number. This means that, given two numbers a and b, the expression ‘a**b’ calculates the value of a raised to the power of b.
🌐
TutorialsPoint
tutorialspoint.com › What-does-double-star-and-star-do-for-parameters-in-Python
What does ** (double star) and * (star) do for parameters in Python?
September 9, 2023 - While creating a function the single asterisk (*) defined to accept and allow users to pass any number of positional arguments. And in the same way the double asterisk (**) defined to accept any number of keyword arguments. The single asterisk (*) ca
Top answer
1 of 16
3343

The *args and **kwargs are common idioms to allow an arbitrary number of arguments to functions, as described in the section more on defining functions in the Python tutorial.

The *args will give you all positional arguments as a tuple:

Copydef foo(*args):
    for a in args:
        print(a)        

foo(1)
# 1

foo(1, 2, 3)
# 1
# 2
# 3

The **kwargs will give you all keyword arguments as a dictionary:

Copydef bar(**kwargs):
    for a in kwargs:
        print(a, kwargs[a])  

bar(name='one', age=27)
# name one
# age 27

Both idioms can be mixed with normal arguments to allow a set of fixed and some variable arguments:

Copydef foo(kind, *args, bar=None, **kwargs):
    print(kind, args, bar, kwargs)

foo(123, 'a', 'b', apple='red')
# 123 ('a', 'b') None {'apple': 'red'}

It is also possible to use this the other way around:

Copydef foo(a, b, c):
    print(a, b, c)

obj = {'b':10, 'c':'lee'}

foo(100, **obj)
# 100 10 lee

Another usage of the *l idiom is to unpack argument lists when calling a function.

Copydef foo(bar, lee):
    print(bar, lee)

baz = [1, 2]

foo(*baz)
# 1 2

In Python 3 it is possible to use *l on the left side of an assignment (Extended Iterable Unpacking), though it gives a list instead of a tuple in this context:

Copyfirst, *rest = [1, 2, 3, 4]
# first = 1
# rest = [2, 3, 4]

Also Python 3 adds a new semantic (refer PEP 3102):

Copydef func(arg1, arg2, arg3, *, kwarg1, kwarg2):
    pass

Such function accepts only 3 positional arguments, and everything after * can only be passed as keyword arguments.

Note:

A Python dict, semantically used for keyword argument passing, is arbitrarily ordered. However, in Python 3.6+, keyword arguments are guaranteed to remember insertion order. "The order of elements in **kwargs now corresponds to the order in which keyword arguments were passed to the function." - What’s New In Python 3.6. In fact, all dicts in CPython 3.6 will remember insertion order as an implementation detail, and this becomes standard in Python 3.7.

2 of 16
851

It's also worth noting that you can use * and ** when calling functions as well. This is a shortcut that allows you to pass multiple arguments to a function directly using either a list/tuple or a dictionary. For example, if you have the following function:

Copydef foo(x,y,z):
    print("x=" + str(x))
    print("y=" + str(y))
    print("z=" + str(z))

You can do things like:

Copy>>> mylist = [1,2,3]
>>> foo(*mylist)
x=1
y=2
z=3

>>> mydict = {'x':1,'y':2,'z':3}
>>> foo(**mydict)
x=1
y=2
z=3

>>> mytuple = (1, 2, 3)
>>> foo(*mytuple)
x=1
y=2
z=3

Note: The keys in mydict have to be named exactly like the parameters of function foo. Otherwise it will throw a TypeError:

Copy>>> mydict = {'x':1,'y':2,'z':3,'badnews':9}
>>> foo(**mydict)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() got an unexpected keyword argument 'badnews'
🌐
Bas
bas.codes › posts › python-asterisks
All you need to know about Asterisks in Python - Bas codes
May 25, 2022 - If you call the last function with ... operators do not only work for function definitions and calls, but they can be used to construct lists and dictionaries....
🌐
Quora
quora.com › What-do-the-two-asterisks-signify-in-C++-when-passing-int-**array
What do the two asterisks signify in C++ when passing (int **array)? - Quora
Answer (1 of 10): It usually signifies a C programmer who’s making a mistake because he hasn’t learned to use C++ yet. As others have already pointed out, syntactically, something like `T **foo;` means foo is a pointer to a pointer to a T (where T is some arbitrary type).
🌐
Real Python
realpython.com › python-asterisk-and-slash-special-parameters
What Are Python Asterisk and Slash Special Parameters For? – Real Python
October 21, 2023 - Each of your final two calls results in a TypeError because you’ve passed arguments by position. Placing the asterisk as the first parameter means that you must provide all arguments as keyword arguments. The error messages tell you where you went wrong. In Python, any argument that’s not passed by keyword is passed by position.
🌐
Trey Hunner
treyhunner.com › 2018 › 10 › asterisks-in-python-what-they-are-and-how-to-use-them
Asterisks in Python: what they are and how to use them
October 11, 2018 - There are a lot of places you’ll see * and ** used in Python. These two operators can be a bit mysterious at times, both for brand new programmers and for folks moving from many other programming languages which may not have completely equivalent operators.
🌐
GeeksforGeeks
geeksforgeeks.org › python-star-or-asterisk-operator
Python - Star or Asterisk operator ( * ) - GeeksforGeeks
April 25, 2025 - It is commonly used for multiplication, unpacking iterables, defining variable-length arguments in functions, and more. In Multiplication, we multiply two numbers using Asterisk / Star Operator as infix an Operator.
🌐
GeeksforGeeks
geeksforgeeks.org › python › what-does-the-double-star-operator-mean-in-python
What does the Double Star operator mean in Python? - GeeksforGeeks
July 23, 2025 - The ** (double star)operator in Python is used for exponentiation. It raises the number on the left to the power of the number on the right.
🌐
Python documentation
docs.python.org › 3 › reference › expressions.html
6. Expressions — Python 3.14.3 documentation
5 days ago - A double asterisk ** denotes dictionary unpacking. Its operand must be a mapping. Each mapping item is added to the new dictionary. Later values replace values already set by earlier dict items and earlier dictionary unpackings.