kwargs in Python

0 votes
Uses for **kwargs in Python?

I know you can do an objects.filter on a table and pass in a **kwargs argument.

How exactly does it work? Is it classes as 'unpacking'? Like a,b=1,2?
Oct 31, 2018 in Python by findingbugs
• 3,140 points
14 views

1 answer to this question.

0 votes

kwargs in **kwargs is just variable name. You can very well have **anyVariableName

kwargs stands for "keyword arguments". But I feel they should better be called as "named arguments", as these are simply arguments passed along with names (I dont find any significance to the word "keyword" in the term "keyword arguments".  we give namesparam1 and param2 to two parameter values passed to the function as follows: func(param1="val1",param2="val2"), instead of passing only values: func(val1,val2). Thus, I feel they should be appropriately called "arbitrary number of named arguments" as we can specify any number of these parameters (that is, arguments) if func has signature func(**kwargs)

answered Oct 31, 2018 by Priyaj
• 56,160 points

Related Questions In Python

0 votes
0 answers

what is the use of args and kwargs in python?

can you an example for each? READ MORE

May 10 in Python by Waseem
• 3,520 points
20 views
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

answered Mar 31, 2018 in Python by DareDev
• 6,810 points
89 views
+2 votes
2 answers

How can I create a new file in Python?

You can try the below code which ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,420 points
69 views
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,420 points
1,150 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 134 views
0 votes
1 answer

*args and **kwargs in python

In cases when we don’t know how ...READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 56,160 points
25 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

answered Apr 3, 2018 in Python by charlie_brown
• 7,710 points
1,333 views