In the following method definitions, what does the *
and **
do for param2
?
1 2 |
def foo(param1, *param2): def bar(param1, **param2): |
===========
The *args
and **kwargs
is a common idiom to allow arbitrary number of arguments to functions as described in the section more on defining functions in the Python documentation.
The *args
will give you all function parameters as a tuple: Continue reading “[Python] What does ** (double star/asterisk) and * (star/asterisk) do for parameters?”