If I declare a function with non keyword arguments such as a tuple and keyword arguments such as a dictionary, are they declared?
For example:
def someFunc(a, *nkw, **kwa):
nkwList = []
kwList = []
for i in nkw:
nkwList.append(i)
for j in kwa:
kwList.append(j)
print a, nkwList, kwList
Input:
someFunc(1)
Output:
1 [] []
As you can see, even though I did not pass a tuple and a dictionary, I didnot get Index out of range error when I loop through nkw and kwa. From my understanding, I think *nkw and **kwa are created in the function declaration itself.
Can anyone help me understand this concept?
The tuple and dictionary are always created, even if they are empty (i.e. nothing was passed in them).