3 ms·
Surprised to see this works for list() as well. >>> def func(b, a=list()): ... a.append(b) ... print(a) ... >>> func(3) [3] >>> func(3)
by MisterBiggs 4y ago
Surprised to see this works for list() as well.
>>> def func(b, a=list()):
... a.append(b)
... print(a)
...
>>> func(3)
[3]
>>> func(3)
[3, 3]
Honestly surprised this quirk hasn't bit me yet