What is the 'pythonic' way to implement a waterfall if-statement like situation like this, when it applies to kwargs
? I'm trying to avoid a situation where c=None
is added to kwargs
(because having c
in the kwargs
keys causes all sorts of problems downstream).
def run_something(**kwargs):
print(kwargs)
def func(a = None, b=None, c=None):
if a and b and c:
run_something(a=a,b=b,c=c)
elif a and b:
run_something(a=a,b=b)
elif a:
run_something(a=a)
else:
run_something()
I know the easy answer is that I could just do:
def func(**kwargs):
run_something(**kwargs)
however my particular use case doesn't make this easy