Yes, you could do what you suggest and pass the arguments as two separate lists:
def A(B, B_args, C, C_args):
B(*B_args) # Use function B
C(*C_args) # Use function C
This will get the job done, but something that is slightly ugly about this is that it would prevent the use of keyword arguments with B
and C
, which is sometimes strongly desired for clarity. Adding separate args and kwargs arguments for each function also seems clumsy.
For a more general approach, I would recommend binding the arguments to the functions outside of the body of A
, which would give you the full power of Python's function call mechanisms in a simple way:
import functools
def A(B, C):
B() # Use function B
C() # Use function C
# Call A while mix-and-matching positional and keyword args
A(functools.partial(B, 1, 2, 3), functools.partial(C, foo=bar))