I have a function
foo(x, setting1=def1, settings2=def2)
(actually this is a third party library function with a bunch of default parameters of which I need to set only 1 externally, but for the sake of example..)
I am calling this from
bar(y, settings2_in=def2)
x = get_x(y)
foo(x, settings2=settings2_in)
This is ok, but stylistically I'd rather call name the parameter settings2_in settings2. When I keep passing another layer down, I'll have to keep renaming the parameter, and it gets ugly.
bletch(z, settings2_in_2=def2)
y = get_y(z)
bar(y, settings2_in=settings_in_2)
Is there a "nice"/Pythonic way to pass a subset of default parameters down many layers of functions in this way?
Is Python clever enough to work out that if I do:
bar(y, settings2=def2)
x = get_x(y)
foo(x, settings2=settings2)
That the 2 uses of settings2 are different from the context?
bar(y, **kwargs)thenfoo(x, **kwargs)I guess