0

Can anyone explain **kwargs to me?

29th Jan 2016, 11:20 AM
Debayan Das
Debayan Das - avatar
2 Antworten
+ 2
Keyword arguments stores the keys with values like dictionary
19th Mar 2016, 6:26 PM
Santhosh Kumar
Santhosh Kumar - avatar
0
Taking the example from the course: def my_func(x, y=7, *args, **kwargs): print(kwargs) my_func(2, 3, 4, 5, 6, a=7, b=8) If you consider the arguments passed to my_func, 2 will be x, 3 will be a non-default value for y, 4, 5 and 6 will be the tuple args and a=7 and b=8 will become the dict kwargs. So args = (4, 5, 6) and kwargs = {'a': 7, 'b': 8}
2nd Jul 2017, 4:26 AM
kiwi