function-parameter

What do * (single star) and / (slash) do as independent parameters?

What do * (single star) and / (slash) do as independent parameters? Question: In the following function definition, what do the * and / account for? def func(self, param1, param2, /, param3, *, param4, param5): print(param1, param2, param3, param4, param5) NOTE: Not to mistake with the single|double asterisks in *args | **kwargs (solved here) Asked …

Total answers: 2

Python – use list as function parameters

Python – use list as function parameters Question: How can I use a Python list (e.g. params = [‘a’,3.4,None]) as parameters to a function, e.g.: def some_func(a_char,a_float,a_something): # do stuff Asked By: Jonathan Livni || Source Answers: Use an asterisk: some_func(*params) Answered By: Mark Byers You can do this using the splat operator: some_func(*params) This …

Total answers: 4