I find that I run into this often. I'll have a core function with a bunch of parameters that needs to run a helper function with the same parameters. Right now I feel like I'm being too explicit when calling the helper function so it feels long winded:
def masterFunc(a, b, c, arg1=1, arg2=2, arg3=3):
utilFunc(a, b, c, arg1, arg2, arg3)
def utilFunc(a, b, c, arg1=1, arg2=2, arg3=3):
print "do the thing"
masterFunc("a", "b", "c")
I suppose I can use **kwargs
to make it more procedural but creating the dictionary still feels long winded:
def masterFunc(a, b, c, arg1=1, arg2=2, arg3=3):
utilFunc(**{"a": a,
"b": b,
"c": c,
"arg1": arg1,
"arg2": arg2,
"arg3": arg3})
def utilFunc(**kwargs):
print "do the thing"
Is there a more elegant way to pass the same arguments to another function? I feel like I'm missing something.
I don't want to use *args
or **kwargs
for masterFunc
as I find it makes it too obscure to know at a glance what parameters it requires.