This one should be simple. Say I have a function and I call some function from some package within my function. I want to customize passing arguments to the package of the function on whether the user has passed arguments to my function. Example code:
import SomePackage as sp
def myFunc(foo, bar, baz=None, xad=False):
# some code to do some stuff...
# then finally:
if baz is not None:
sp.someFunc(data=foo, method=bar, aux=baz)
else:
sp.someFunc(data=foo, method=bar)
Is there a way to replace the last 4 lines with just one neat Pythonic line? Something like:
def myFunc(foo, bar, baz=None, xad=False):
# some code to do some stuff...
# then finally:
sp.someFunc(data=foo, method=bar, [aux=baz if baz is not None])