Steven D'Aprano wrote: > On Wed, Jan 10, 2018 at 07:29:58PM +0100, Peter Otten wrote: > > [...] >> elif not isinstance(obj, property): >> attrs[attr] = property(lambda self, obj=obj: obj) > >> PS: If you don't remember why the obj=obj is necessary: >> Python uses late binding; without that trick all lambda functions would >> return the value bound to the obj name when the for loop has completed. > > This is true, but I think your terminology is misleading. For default > values to function parameters, Python uses *early* binding, not late > binding: the default value is computed once at the time the function is > created, not each time it is needed.
You are right; I should have stated clearly where I was talking about the closure. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor