Is it mandatory to pass tuple to *arguments and dictionary to **keywords while calling a function,What type of function is this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it mandatory to pass tuple to *arguments and dictionary to **keywords while calling a function,What type of function is this?

Can we pass some other datastructure to *arguments apart from tuple,som other datastructure to **keywords apart from dictionary? def cheeseshop(kind, *arguments, **keywords): ........................ ....some codes

3rd Jun 2021, 8:01 AM
lisa
3 Answers
+ 5
no, when you call such function, you doesn't pass tuple to *arguments nor dictionary to **keywords... except if you unpack them ^^ however, inside the function you receive a tuple in 'arguments' variable and a dictionary in 'keywords' variable (or whatever you call them)... you call the function with any number of unamed arguments and/or named arguments, and they are packed as tuple/dictionary: cheeseshop(required, arg1, arg2, key1=val1,key2=val2,key3=val3) inside function you get: kind == required arguments == (arg1, arg2) keywords == {key1=val1, key2=val2, key3==val3}
3rd Jun 2021, 8:23 AM
visph
visph - avatar
3rd Jun 2021, 8:23 AM
Manohar Yadav
Manohar Yadav - avatar
+ 1
visph Got it, Best answer.
3rd Jun 2021, 10:45 AM
lisa