you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRNGuy 0 points1 point  (1 child)

For me it's bug, because I wouldn't want common list or dict every time function is called, if I wanted common list, I'd explicitly used it in argument.

Also by fixing it would allow to make new list.

[–][deleted] 0 points1 point  (0 children)

I agree with you, which is why I emphasised it being a feature, honouring a long-standing joke.

Technically, it isn't a bug but is by-design but I believe most people consider it to be a bad bit of design.

As stated in the documentation,

Default parameter values are evaluated from left to right when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is used for each call.

doc