Linked Questions
603 questions linked to/from What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
1596
votes
11
answers
986k
views
Use of *args and **kwargs [duplicate]
So I have difficulty with the concept of *args and **kwargs.
So far I have learned that:
*args = list of arguments - as positional arguments
**kwargs = dictionary - whose keys become separate keyword ...
863
votes
13
answers
749k
views
What is the purpose and use of **kwargs? [duplicate]
What are the uses for **kwargs in Python?
I know you can do an objects.filter on a table and pass in a **kwargs argument.
Can I also do this for specifying time deltas i.e. timedelta(hours = time1)?
...
404
votes
5
answers
324k
views
What does asterisk * mean in Python? [duplicate]
Does * have a special meaning in Python as it does in C? I saw a function like this in the Python Cookbook:
def get(self, *a, **kw)
Would you please explain it to me or point out where I can find an ...
300
votes
5
answers
202k
views
What do *args and **kwargs mean? [duplicate]
What exactly do *args and **kwargs mean?
According to the Python documentation, from what it seems, it passes in a tuple of arguments.
def foo(hello, *args):
print(hello)
for each in args:
...
144
votes
3
answers
135k
views
What do * and ** before a variable name mean in a function signature? [duplicate]
What do the * and ** mean in this code?
def functionA(self, *a, **kw):
# code here
hqt's user avatar
- 30.4k
86
votes
1
answer
38k
views
Python method/function arguments starting with asterisk and dual asterisk [duplicate]
I am not able understand where does these type of functions are used and how differently these arguments work from the normal arguments. I have encountered them many time but never got chance to ...
25
votes
2
answers
62k
views
What does "**" mean in python? [duplicate]
Simple program:
storyFormat = """
Once upon a time, deep in an ancient jungle,
there lived a {animal}. This {animal}
liked to eat {food}, but the ...
19
votes
1
answer
11k
views
What does * represent in function argument list in python? [duplicate]
While going through the source code, I noticed the following syntax being used in the asyncio library:
@coroutine
def sleep(delay, result=None, *, loop=None):
"""Coroutine that completes after a ...
7
votes
2
answers
28k
views
Passing a list of parameters into a Python function [duplicate]
How would I pass an unknown number of parameters into a function? I have a function defined in the following way
def func(x, *p):
# do something with variable number of parameters (*p)
pass
I'...
11
votes
2
answers
10k
views
kwargs reserved word in python. What does it mean? [duplicate]
I am using Python trying to figure out a key word and I see the word, "kwargs", which I know is some kind of argument in the called function but I can not find what it means or stands for anywhere.
...
8
votes
1
answer
3k
views
what does double star followed by variable name mean in python? [duplicate]
Possible Duplicate:
What does ** (double star) and * (star) do for python parameters?
I am reading some code that been generated by ZSI for python. There is a line like this
def verifyVehicle(...
6
votes
4
answers
4k
views
In python when passing arguments what does ** before an argument do? [duplicate]
From reading this example and from my slim knowledge of Python it must be a shortcut for converting an array to a dictionary or something?
class hello:
def GET(self, name):
return render....
3
votes
2
answers
10k
views
Pass multiple arguments in form of tuple [duplicate]
I'm passing a lot data around; specifically, I'm trying to pass the output of a function into a class and the output contains a tuple with three variables. I can't directly pass the output from my ...
9
votes
4
answers
4k
views
What is the difference between single asterisk and double asterisks before variable in python? [duplicate]
data = pd.read_csv("customers.csv")
print("Wholesale customers dataset has {} samples with {} features each."
.format(*data.shape))
After this, I got the dimension numbers of the data. But I am ...
1
vote
3
answers
9k
views
What does * do with range() in python? [duplicate]
I was doing a Hackerrank python problem the task was to print 123...N (where N is the input)
without using any string function.
Someone commented a solution which is:
...