Hacker News new | past | comments | ask | show | jobs | submit login

why doesn't python have anonymous functions (not just lambdas which can only be expressions)?



Syntax. Strict indentation rules do not allow using a block of code in an expression.


It lets you define functions on the fly and use them, so the only difference from anonymous functions is that you have to pick a name.


Yeah, I almost wish they didn't use the keyword 'lambda' at all. If you could just write:

    def foo(x):
        def lambda():
          print x
        lambda;bar(callback=lambda);baz(42,lambda)
        def lambda():
          print x * x
        lambda;bar(callback=lambda);baz(42,lambda)
It'd stop this silly complaint. I just end up using 'def lambduh'

Slightly annoying that you need to define the function on the line before, can't inline it, but not nearly as bad as people make it out to be.


Priorities and style. First-class functions are available, and a lot of veteran Python programmers, Guido included, don't like an overwhelmingly functional style.

It's considered opaque.

Personally, I like to fiddle with Clojure in my free time.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: