3 ms·
> "Allowing to elide the add42 from "def add42(x): x+42" makes the difference between encouraging FP or not?" Not being able to define a two-line function in t
by darkpuma 8y ago
> "Allowing to elide the add42 from "def add42(x): x+42" makes the difference between encouraging FP or not?"
Not being able to define a two-line function in the place where it's used because you have to give it a name discourages FP in a way many other modern languages do not.
- stormking 8y agoNot really, since Python can nest functions: def something(x): def myfunc(y, z): ... return result reduce(myfunc, x) So the difference is like having to write x = some_very_complex_expression_that_can_get_quite_long some_function(x) instead of some_function(some_very_complex_expression_that_can_get_quite_long) In many cases this may make code even more readable. I'm not saying that Python's lambdas are perfect as they are or that multi-line lambdas would be a bad thing. I'm just saying it's not as bad as you paint it.