3 ms·
Weird, I thought that Python was trying to discourage functional programming with its extremely limited lambdas and the proposal to move map and reduce out of t
by technomancy 10y ago
Weird, I thought that Python was trying to discourage functional programming with its extremely limited lambdas and the proposal to move map and reduce out of the core language.
- brianwawok 10y agoKinda. Many things you can do with a map can also be done with a list comprehension or generator, so that seems to be the way to go. Moving from Scala to Python it was annoying at first.. but honestly the code is easier to read in most cases, so no complaints here.
- LyndsySimon 10y agoIIRC, the limitations on lambdas has to do with the way whitespace is parsed rather than being an explicitly conscious decision.
- andybak 10y agoGuido also maintains that by the time you need multiline lambda's, the extra cost of giving the function a name is more than outweighed by the improved readability. I kinda agree. Certainly it guards against some of the code you see in overly nested javascript. The downside is that the code is slightly removed from it's call site - but rarely by much. Overall the increased complexity it would bring to the language has not been justified by anyone arguing for it's benefits. Giving the function a name isn't the worst thing in the world.
- andybak 10y agoThe important thing is to fully support first class functions - not the fact that they are anonymous - so I find it difficult to see how the lack of multiline anonymous functions is really a blow to functional Python I think the argument against map and reduce was that there was better and more Pythonic ways to do both - not because they were 'too functional'.