scope of optional arguments

cseja p5secr2 at uni-jena.de
Mon May 19 10:43:47 EDT 2008


Whoops, I meant to call

print walk([1,2,3], [])
print walk([4,5,6])

and

print walk([1,2,3])
print walk([4,5,6])

with

def walk(seq, result = []):
  for item in seq:
    result.append(item)
  return result

The question is still the same: Why do both calls give different results?

Thank you very much for reading, I'm sorry for the inconvenience. 





More information about the Python-list mailing list