I have two functions:
def foo(*args, **kwargs):
pass
def foo2():
return list(), dict()
I want to be able to pass the list and dict from foo2 as args and kwargs in foo, however when I use it like
foo(foo2())
or
foo(*foo2())
tuple returned by foo2 gets assigned to *args. How should I do it properly?
You'll have to unpack your foo2()
arguments into two names first, you can't directly use the two return values as *args
and **kwargs
with existing syntax.
Use:
args, kwargs = foo2()
foo(*args, **kwargs)