4 ms·
I never understood his desire to remove 'reduce' from Python. I would love to hear a cogent reason as to why we should have to write a for-loop for everything '
by wheaties 10y ago
I never understood his desire to remove 'reduce' from Python. I would love to hear a cogent reason as to why we should have to write a for-loop for everything 'reduce' like. In other languages, 'reduce' (akin to 'fold' for non-Python people) is one of the things you reach for daily.
- empath75 10y ago`from functools import reduce`
- d0mine 10y agoIt is still available as functools.reduce An explicit loop is easier to read as a rule than the corresponding reduce() code. See http://stackoverflow.com/questions/15995/useful-code-which-uses-reduce-in-python http://stackoverflow.com/questions/15995/useful-code-which-u...
- jghn 10y ago"Easier to read" for some people, I think you mean
- talideon 10y agoThe main issue is syntactic: Python's syntax is such that reduce() isn't terribly useful. If Python had an equivalent of blocks in Ruby or at least the ability to write non-trivial lambdas, I can see reduce() being useful, but as things stand, it's just kind of useless.