0

What are the meaning of * if it given as argument?also what are various meaning of * in python?

26th Dec 2018, 11:11 AM
shreyash joshi
shreyash joshi - avatar
2 Respostas
+ 4
It can be used for tuple unpacking like a,b,c,*d = 1,2,3,4,5,6 here all extra values are packed in d as a list print(d) >[4,5,6] It can be used to unpack values in a function like print(*d) 4 5 6 It can be used to define arbitrary number of parameters in function definition, as honfu said It can be also used as keyword arguments, same as above but instead of packing arguments as tuple it store them as dict Its usage is **kwargs in function definition. These are some i remember atm
26th Dec 2018, 12:54 PM
Mayank
Mayank - avatar
+ 1
Using * with a function parameter x allows you to pass as many arguments as you want, they'll all be put into a tuple with the name x.
26th Dec 2018, 12:04 PM
HonFu
HonFu - avatar