I very recently learned about dict().setdefault()
For instance:
def myfunc(**kwargs):
# we need to be sure kwargs has ['foo'] set, with 'bar' as the default:
kwargs['foo'] = kwargs.get('foo', 'bar')
We could write that this way: def myfunc(**kwargs):
kwargs.setdefault('foo', 'bar')