I thought I had learn python and that parameters/arguments (which is the correct term?) were just local variables within the method and if they were not declared in the method call then they would take their defined default values. This example clearly shows that I'm wrong:
This code
def example(foo=[]):
print foo
bar = 'Hello world'
foo.append(bar)
return foo
print example()
print example()
prints out this
[]
['Hello world']
['Hello world']
['Hello world', 'Hello world']
I would have expected it to print out:
[]
['Hello world']
[]
['Hello world']
Why doesn't that happen _?
I know that
print example([])
print example([])
prints what I expect. But that kinda miss the point of having default values..
Bonus info: Using Python 2.7.3 and IPython