[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan
New submission from X. Yan : I am familiar with quite a few languages such as C++, C, PASCAL, Matlab, etc., but starting to practice Python. When I tested the code: def f(a, L=[]): L.append(a) return L followed by calls as follows, v1 = f(1) v2 = f(2) , to my surprise, I

[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan
X. Yan added the comment: Hi Serhiy, Thanks for your reply. However, the issue I reported was not about sharing the default value. I understand that the parameter L would keep its value [1] from function f's first run, and used it in the second run to get [1, 2]. My point is tha

[issue33835] Too strong side effect?

2018-06-11 Thread X. Yan
X. Yan added the comment: I see. Thanks for the detailed explanations. Best, Xiaogang On 6/11/2018 2:00 PM, Steven D'Aprano wrote: > Steven D'Aprano added the comment: > > Both names "v1" and "v2" refer to the same object. Python does not make >