[Python-ideas] Rehabilating reduce (as "fold")

Andrew Barnert abarnert at yahoo.com
Fri Jul 12 18:01:42 CEST 2013



Sent from a random iPhone

On Jul 12, 2013, at 1:49, Joshua Landau <joshua at landau.ws> wrote:

> On 12 July 2013 09:03, Andrew Barnert <abarnert at yahoo.com> wrote:
>>> I'd personally be in favour of the notion of also allowing strings as the first argument, so you could instead write:
>> 
>>> 
>>>   data = fold("+=", [], iterables)
>> 
>> 
>> I like this idea, but only if it's added to other functions in the stdlib where it makes sense, and easy to add to new functions of your own.
> 
> Is there a use-case for that last part? It strikes me as equivalent to
> messing with builtins, which is largely unliked.

I think you missed the word "to" in "add to". I don't want to create functions that can be passed to fold as if they were operators, I want to create functions that can take operators the same way fold does.

The former is akin to messing with builtins, which is bad; the latter is akin to using them.


More information about the Python-ideas mailing list