On Thursday, December 11, 2014 12:09:10 AM UTC+5:30, rand...@fastmail.us wrote: > 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
Ok. As I wrote in the "Question on lambdas" thread yesterday lambdas and defs are equivalent And going the other way -- no defs only lambdas its this: >>> f = lambda : (lambda x= {}: x) >>> f()() is f()() False >>> d = f() >>> d() is d() True >>> But I have a different question -- can this be demonstrated without the 'is'? Because to me 'is' -- equivalently id -- is a code-smell and is like explaining funny behavior by showing the dis -- like $ gcc -S ... -- output. It can always explain, but indicates that the semantics is not (sufficiently) abstract in this aspect -- https://mail.python.org/mailman/listinfo/python-list