Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python varargs before function name?

I'm doing some Python coding in a clients code base and I stumbled on a line of code that looks something like this (the variable names have been changed to protect the innocent):

reply = function1(a=foo, **function2(bar, b=baz))

Normally ** in the argument list collects remaining keyword arguments but what do they do in front of the function name?

like image 761
Jörgen Lundberg Avatar asked Dec 08 '25 08:12

Jörgen Lundberg


1 Answers

I'd say that this is just calling a function that returns a dict-like object and therefor the asterisks just convert the returned dict into the keyword arguments for function1, just as usual.

like image 122
Horst Gutmann Avatar answered Dec 09 '25 22:12

Horst Gutmann