I have a function that iterates over a many levels nested dictionary (arg1) collecting data over each iteration, something like this:
def dummy(arg1, found=[], index=0):
found.append('xyz')
for d in arg1:
dummy(arg1[d], found, index+1)
return found
My functions work as it's supposte to, the problem is that when I call the function a second time, the found argument keeps the value from the previous function call, i.e. the return value from the second call includes the return values from the previous call. I had to add something like
if index == 0:
found=list() # restart value
to the beginning of the function to initialize the value of the found argument. Any idea why this happens? is this a bug?