It’s passed by value of reference. So modifications to the object can be seen outside the function, but assigning the variable to a new object does not change anything outside the function.
It’s essentially the same as passing a pointer in C, or a reference type in Java.
The result of the +=
case is because that operator actually modifies the list in place, so the effect is visible outside the function. lst.append()
is also an in-place operation, which explains your last case.
No comments:
Post a Comment