def foo(l=None, d=None):
return bar(*l, **d) # eg. bar(1, 2, 3, a=a, b=b)
Input:
l = [1, 2, 3]
d = {'a': a, 'b': b}
foo(l=l, d=d)
Problem arises when l
is None
, ie. this call is made:
foo(d={'a':a})
What do I change in foo
to handle NoneType
on both the list and the dict nicely?
This is ugly, there has to be a better way than this:
def foo(l=None, d=None):
if l is not None and d is not None:
return bar(*l, **d)
if l is not None:
return bar(*l)
if d is not None:
return bar(**d)