News for hackers. Stuff that matters.
Re:Unpythonic Python by clickok on Wednesday April 09, 2014 @03:35PM (#7561773)
"let = lambda" would be the same thing, wouldn't it?
Re:Unpythonic Python by exDM69 on Wednesday April 09, 2014 @03:39PM (#7561792)
Yes, but in an incredibly verbose way. And a simple let->lambda conversion can't express things that Scheme's let* or letrec expressions let you do (in Haskell, a "let" or "where" expression is a "letrec").
Re:Unpythonic Python by aaren on Wednesday April 09, 2014 @04:11PM (#7562008)

    >>> let = lambda
      File "<stdin>", line 1
        let = lambda
               ^
    SyntaxError: invalid syntax
Am I misunderstanding you?
Re:Unpythonic Python by farinasa on Wednesday April 09, 2014 @04:17PM (#7562048)
>>> let = lambda x: 2*x

>>> print let(4)

8

Edit: Awesome, downvoted for helping.

Re:Unpythonic Python by Ideka on Wednesday April 09, 2014 @06:35PM (#7562968)
That's not what they mean. The usage they are discussing is more like this, I believe. In a functional context, instead of doing:

    print expensive_computation(), expensive_computation()
You can do:

    (lambda x: print x, x)(expensive_computation())
Which would be equivalent to, with an imaginary let syntax:

    (let x be expensive_computation(): print x, x)