Consider the following code:
def f(a=()): print(a) a += (1) f() f() f()
() (1) (1,1)
This behavior seems peculiar. Shouldn’t the parameter
a be reset to
() each time the function runs?
When the parameter is an integer I get the expected behavior:
def f(a=1): print(a) a += 1 f() f() f()
1 1 1
I realize lists are mutable and integers aren’t, but I can’t figure out if that would matter here.