This is my code. I was observing data type of args in def
function.
>>> def example(a,b=None,*args,**kwargs):
... print a, b
... print args
... print kwargs
...
>>> example(1,"var",2,3,word="hello")
1 var
(2, 3)
{'word': 'hello'}
>>> _args = (1,2,3,4,5)
>>> _kwargs = {"1":1,"2":2,"3":3}
>>> example(1,"var",*_args,**_kwargs)
1 var
(1, 2, 3, 4, 5)
{'1': 1, '3': 3, '2': 2}
When the 2, 3
of actual parameters (arguments) to a function pass as *arg
of formal parameters; thus, arguments are passed using call by value (where the value is always an object reference, not the value of the object).
*args
in the call expands each element in my sequence (be it tuple or list) into separate parameters. Those separate parameters are then captured again into the *args
argument, why is it always a tuple
?