For example, this doesn't do what people expect:
def foo(bar=Bar())
...
Because this creates exactly one Bar at function definition time, not a Bar per function call.Instead what people usually want is:
def foo(bar=None)
if bar is None:
bar = Bar()
...
I hate having to have a block of `if bar is None` at the top of my functions.I wonder if there's a library that helps make creating functions with default args easier? Or any tips people have?