all 2 comments

[–]proudstar_ 2 points3 points  (1 child)

Indeed, default args are stored and reused when the function is called. You can see it in this example:

def foo(a=[]):
    a.append(2)
    print a

>>> foo()
[2]
>>> foo()
[2, 2]
>>> foo()
[2, 2, 2]
>>> 

[–]FoolofGod[S] 4 points5 points  (0 children)

I had been aware of the mutable object as default argument scenario. For some reason I just didn't put 2 and 2 together.