Y
Hacker News
new
|
ask
|
show
|
jobs
by
saltylicorice
3819 days ago
The problem is that the default argument is mutable.
def f(a=[]): a.append('v') print a f(['ok']) # ['ok', 'v'] f() # ['v'] f() # ['v', 'v']
1 comments
throwaway91919
3819 days ago
Ah, thanks.
link