I am trying to use defaultdict to store several lambdas that take one param, but to respond with a default lambda with the key is missing. I get an error when trying to use the default:
d = defaultdict(lambda str: str)
d['a'] = lambda str: f"aaa{str}"
d['a']('hello')
>>> 'aaahello'
d['b']('hello')
>>> <lambda>() missing 1 required positional argument: 'str'