Comment on Surprised by Python lambdas on 22 dec 2009
Comment by Buy Valium ilan timelines cursor confusingly adopts fondsenzw bahadur accepted pharmaceutic stove typically semelokertes marchimundui
View ArticleComment on Surprised by Python lambdas on 11 nov 2009
Comment by Lennart Regebro Lambdas are just anonymous functions. It gets easier when you realize that >>> for i in range(3):... l.append(lambda: set(i)) Can be written >>> def...
View ArticleComment on Surprised by Python lambdas on 10 nov 2009
Comment by rgz Me too, creating anonymous classes in Java is depressingly verbose. I don't think Python users suffer excessive language envy, we don't see much clamor for automatic variables or...
View ArticleComment on Surprised by Python lambdas on 10 nov 2009
Comment by Michael Foord Sorry, I should have said *another* way of capturing the value bound to a name inside a loop is to use the default argument. Your ways are completely valid of course....
View ArticleComment on Surprised by Python lambdas on 10 nov 2009
Comment by Paul Boddie This behaviour changed when closures were added to Python. Previously, lambdas had their own strict local scope and the only way to capture state from the function in which the...
View ArticleComment on Surprised by Python lambdas on 10 nov 2009
Comment by Jonathan Hartley Ah-ha! I didn't realise that either. Thanks for the write-up!
View ArticleComment on Surprised by Python lambdas on 09 nov 2009
Comment by Orestis Markou That makes sense although it looks ugly IMO. I knew about how loops don't create a new scope, but this is the first time I'm actually bitten by that - I guess I don't use...
View ArticleComment on Surprised by Python lambdas on 09 nov 2009
Comment by Michael Foord The normal way of capturing the current value of a name in a lambda is: lambda i=i: set(i) The default value is bound immediately and doesn't have the late bound problems with...
View Article
More Pages to Explore .....