News for hackers. Stuff that matters.
Re:What’s New in Python 3.0 by KirinDave on Saturday June 21, 2008 @10:57AM (#223697)
I really wish they had added real lambdas.

Don't get me wrong, these changes seem good. But every time I hear about a new Python release I keep hoping that I'll see they've finally reversed their policy about lambdas and made a real one instead of the compromise they have right now.

Re:What’s New in Python 3.0 by eru on Saturday June 21, 2008 @12:24PM (#223734)
You should be yearning for proper tail recursion instead.
Re:What’s New in Python 3.0 by KirinDave on Monday June 23, 2008 @11:16AM (#225179)
I can live without this. I cannot live without real lambdas. My heart actually will stop, and I will die. It's a dangerous world I live in.
Re:What’s New in Python 3.0 by globalrev on Saturday June 21, 2008 @11:20AM (#223709)
what does a real one consitute of?

and why do you want that? i use pyhton as a superb general-purpose language and for gluing together a lot of different parts of software/programs.

for that purpose, simplicity and readability is essential.

Re:What’s New in Python 3.0 by bkovitz on Saturday June 21, 2008 @04:02PM (#223826)
Sometimes, I just want to pass a function to a function. And sometimes, I want to just say, very concisely, "do this", without giving a name to "this".
Re:What’s New in Python 3.0 by schtog on Saturday June 21, 2008 @07:31PM (#223933)
But you can do that in both python 3 and 2.5...
Re:What’s New in Python 3.0 by kilowatt on Saturday June 21, 2008 @09:45PM (#223985)
Maybe he's talking about

    >>> funcs = []
    >>> for x in xrange(3):
    >>>   funcs.append(lambda: x)
    >>> sum(f() for f in funcs)
    6
Were you expecting 3? Lambdas (besides having such an awfully long and difficult to type name :P) capture only the "name" of x, so when the for loop changes x later, the lambda sees the new value--so the sum is (2 + 2 + 2) instead of (1 + 2 + 3).

What you can do, instead (and I do it often enough that I wish lambdas created their own lexical closure....)

    >>> funcs = []
    >>> for x in xrange(3):
    >>>   funcs.append(lambda x=x: x)
    >>> sum(f() for f in funcs)
    3
By using x as a default argument, you force the x inside the lambda to be the value it was when the lambda was created. It kinda sucks, and always felt to me like a deficiency of the implementation leaking up into the language :[
Re:What’s New in Python 3.0 by matstc on Saturday June 21, 2008 @11:00PM (#224011)
I think you mean "2 + 2 + 2 instead of 0 + 1 + 2"