12 Why the asterisk in the parameter


#1

Hi I wanted to understand why there is an asterisk in the parameter of the function. It it doing something? It looks like its allowing a list as the argument of the function, instead of just a single variable.


#2

It is a wildcard placeholder for undetermined number of arguments. There can be only one in the parameter list, and it must come last.

(some, thing, *splat)

#3

Thank you for clarifying, thats what I was thinking


#4

You’re welcome. This is something to experiment with in your own console or in a sandbox.

Consider that optional arguments might still apply.

(some, thing=False, *splat)

#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.