I have a tuple containing tuples.
EVENT_MAPPING = (
(func1, (paramA1, paramA2, paramA3)),
(func2, (paramB1)),
(func3, (paramC1, paramC2)),
)
I iterate over the first tuple. And I want to call the function contained in the first param with args in the second param plus other param. For example, for the first tuple :
func1(origin, paramA1, paramA2, paramA3)
If their is no the “origin” param, I can have a call thanks to :
args[0](args[1])
But with the extra param (“origin”), I can’t do things like that.
I found a way to do it but it is heavy :
call = tuple(list(args[1]).insert(0,origin))
args[0](call)
Is there a better way to do this ?
Thanks for your help
Like this, probably:
The * extracts (expand) the inner tuple and they are passed to the function as arguments.