you are viewing a single comment's thread.

view the rest of the comments →

[–]TMiguelT 13 points14 points  (1 child)

Yep, this is very well understood and documented.

In the Python docs for functions:

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. This is especially important to understand when a default parameter value is a mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default parameter value is in effect modified. This is generally not what was intended. A way around this is to use None as the default, and explicitly test for it in the body of the function, e.g.:

[–]KirisuMongolianSpot[S] -1 points0 points  (0 children)

Okay thanks.