File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44I have come to see that most new python programmers have a hard time
55figuring out the \* args and \*\* kwargs magic variables. So what are they
6- ? First of all let me tell you that it is not necessary to write \* args
6+ ? First of all, let me tell you that it is not necessary to write \* args
77or \*\* kwargs. Only the ``* `` (asterisk) is necessary. You could have
88also written \* var and \*\* vars. Writing \* args and \*\* kwargs is just a
99convention. So now let's take a look at \* args first.
@@ -12,12 +12,11 @@ Usage of \*args
1212^^^^^^^^^^^^^^^
1313
1414\* args and \*\* kwargs are mostly used in function definitions. \* args
15- and \*\* kwargs allow you to pass a variable number of arguments to a
16- function. What variable means here is that you do not know beforehand
17- how many arguments can be passed to your function by the user
18- so in this case you use these two keywords. \* args is used to send a
19- **non-keyworded ** variable length argument list to the function. Here's
20- an example to help you get a clear idea:
15+ and \*\* kwargs allow you to pass an unspecified number of arguments to a
16+ function, so when writing the function definition, you do not need to
17+ know how many arguments will be passed to your function. \* args is used to
18+ send a **non-keyworded ** variable length argument list to the function.
19+ Here's an example to help you get a clear idea:
2120
2221.. code :: python
2322
You can’t perform that action at this time.
0 commit comments