I have a function (let's call it foo
):
def foo(**kwargs):
if kwargs.get("key") is not None:
key = kwargs["key"]
else:
key = "default"
Here I have a default value for key
but if kwargs
has a value for key
, I want to use that instead.
Is there a way to simplify this onto 1/2 lines?