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

You are correct. There is no reason not to just use an inline function that happens to have a name. I think the "lambdas can only be one line" is a newbie python mistake.



Personally, I dislike naming things that I won't use again. It feels like a waste. And then, since I have to name things, I have to come up with a _good_ name.

Just a matter of taste, mind you, but it's my reasoning for preferring anonymous functions.


They do make code more readable sometimes... but I think they are often used in Ruby as an alternative to @obj.method(:foo) -- in other words the Rubyist would use lambda{@obj.foo} and the pythonista would use obj.foo




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

Search: