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
3 Respostas
+ 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}
+ 1
I think this will help
https://www.geeksforgeeks.org/args-kwargs-JUMP_LINK__&&__python__&&__JUMP_LINK/
+ 1
visph Got it, Best answer.