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

Mathias Panzenböck grosser.meister.morti at gmx.net
Fri Jul 12 15:50:02 CEST 2013


On 07/12/2013 08:01 AM, Nick Coghlan 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'd like to see a more Haskell like way to reference operators:

	data = fold((+=), [], iterables)

(+=) would just be a short syntax for operator.iadd without the need to explicitly import any module. It should
generate the same byte code.

But I have the feeling that won't happen. :/

	-panzi


More information about the Python-ideas mailing list