Copy Function Defaults February 06, 2007
Default arguments to functions are evaluated when the function is created, and are stored in the function object. This cause irritating problems when the default values are in fact mutable, as only single instance exists:
Sometimes it’s the desired behavior, but mostly it’s a bug. To solve that bug, we use
But this idiom adds lots of boilerplate code into functions. The following little decorator solves that problem elegantly.