I would change foo
so it replaces empty values with default ones.
def foo(a, b=None, c=None, d=None):
if not b: b = 1
if not c: c = 2
if not d: d = 3
Note that this will treat all "false-y" values as defaults, meaning not only None
and ''
but also 0
, False
, []
, etc. Personally I would tighten the interface up and use None
and only None
as a default value.
def foo(a, b=None, c=None, d=None):
if b is None: b = 1
if c is None: c = 2
if d is None: d = 3