Hi,
I am learning Python and came across this example in the Python Online
Tutorial (
http://docs.python.org/tutorial/controlflow.html#default-argument-values)
for Default Argument Values.
ex:
def func(a, L=[ ]):
L.append(a)
return L
print func(1)
print func(2)
print func(3)
*O/P*
[1]
[1,2]
[1,2,3]
Now my doubt is,
1) After the first function call, when ' L' (Reference to List object) goes
out of scope, why isn't it destroyed ?
2) It seems that this behavior is similar to static variable logic in C
language. Is it something similar ? OR
Is it related to scope rules in Python ?
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor