This question has already been answered:
Probably many people know an example:
def foo(a=[]): a.append(1) print (a) foo() foo() foo() which issues to print:
[1] [1, 1] [1, 1, 1] >>> I expected to see three identical outputs -
[1] [1] [1] Can you explain the reason for this behavior?
Does the function really store its objects between calls?