Hi I am new to python and come from C language background. I couldn't able to understand this
>>> def f(a, L=[]): ... L.append(a) ... return L ... >>> print(f(1)) [1] >>> print(f(2)) [1, 2] >>> print(f(3)) [1, 2, 3] >>> def f(a, L=10): ... L=10+a ... return L ... >>> print(f(1)) 11 >>> print(f(1)) 11 In the first example if i call function f then it looks like L is treated as a static object which is not reinitialized in the subsequent function calls. But in the second example, it seems to be reinitialized in the subsequent calls. Can anyone explain this or point me to the discussion if it is asked before. Thanks Rishabh Mittal _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor