I would presume that the following code:
def f(k, v, d={}):
if k not in d:
d[k] = v
return d[k]
print(f(0, 'a'))
print(f(0, 'b'))
produces the following output:
>>> a
>>> b
but it actually produces:
>>> a
>>> a
What would explain the dictionary d being already assigned on the second call to f?