3 ms·
I think the way he described it is pretty accurate. Default keyword arguments are only evaluated once at function definition, so supplying a mutable default key
by kilink 12y ago
I think the way he described it is pretty accurate. Default keyword arguments are only evaluated once at function definition, so supplying a mutable default keyword argument can cause issues.
Your example is pretty contrived and doesn't illustrate what he was pointing out, as you're creating a new function foo every time foo2 is called, and only calling it once.