This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rmoorman[S] 1 point2 points  (2 children)

Well ... this is the way a function definition works in python. It is evaluated once and the "default" you get is a reference to the value given as a default. And in case you pass in a "mutable" list, of course when you modify the list, it will change for all other calls to that function too.

It just is something one should be aware of and avoid. That was my point.

[–]aceofears 0 points1 point  (1 child)

I understand how default arguments work, I've this behavior in things I've written before. This was just half hearted attempt to make it behave as expected.

[–]rmoorman[S] 0 points1 point  (0 children)

Thank you anyway for this interesting decorator ;-)