4 ms·
Not for me... >>> def function(item, stuff=[]): print stuff + [item] >>> MODULE_LEVEL_CONSTANT = ['foo', 'bar'] >>> function('baz', MODULE_LEVEL
by andreyf 18y ago
Not for me...
>>> def function(item, stuff=[]):
print stuff + [item]
>>> MODULE_LEVEL_CONSTANT = ['foo', 'bar']
>>> function('baz', MODULE_LEVEL_CONSTANT)
['foo', 'bar', 'baz']
>>> MODULE_LEVEL_CONSTANT
['foo', 'bar']
>>> function('quux', MODULE_LEVEL_CONSTANT)
['foo', 'bar', 'quux']
I think you're confusing + and .append (the latter affects the object).
- jaf656s 18y agoI believe he was referring to use of .append by the author. You defined it the way he recommends, which has the desired behavior.