Hacker News new | ask | show | jobs
by randomguy1254 3549 days ago
lambda bodies can only be a single expression
1 comments

There is more to functional programing in python than lambda functions. Normal functions can be created and passed around.
Sure, but I think that is the point. You can do that, but its not as convenient and becomes harder to read. And besides, those are free functions you speak of, not closures. To emulate multi-line closures becomes even more obtuse.
I find it more readable than lambda function syntax personally. And still way nicer than messing around in JavaScript.
Sorry, I edited my comment and you may have missed it. How would you emulate multi-line closures in Python? A free function which you can pass to a higher order function is not a closure. I think you would need to create a functor, and that becomes even more verbose.
What do you mean by closure in this case?
Closures are functions that can capture values/references visible in the scope where the function is defined/instantiated. They are basically a short hand way of creating function objects, functions which have data members.