On Tue, Dec 9, 2014, at 21:44, Rustom Mody wrote: > Nice example -- thanks. > Elaborates the why of this gotcha -- a def(inition) is imperative. > From a semantic pov very clean. > From an expectation pov always surprising.
Of course, I used a lambda for this. The equivalent without would be: def f(): def g(x={}): return x return g Ultimately it's no different from when any non-immutable expression is executed. def f: return {'x': {}} f()['x'] is f()['x'] # False d = f() d['x'] is d['x'] # True -- https://mail.python.org/mailman/listinfo/python-list