[Python-ideas] map, filter, reduce methods for generators

Paul Moore p.f.moore at gmail.com
Fri Apr 11 00:20:31 CEST 2014


On 10 April 2014 23:09, Jacek Pliszka <jacek.pliszka at gmail.com> wrote:
> OK, if method chaining is a problem, what about:
>
> from StreamAlgebra import Map, Filter, Reduce
> from operator import add
>
> range(100) | Filter(f1) | Map(f2) | Filter(f3) | Map(f4) | Reduce(add)

It's not so much that these types of things are "a problem" - more
that they are simply not common usage in Python, and so are
unfamiliar. You can certainly write code that uses method chaining, or
your StreamAlgebra module. They are entirely legitimate as 3rd party
code. What's less clear is that they belong in the core / stdlib,
because core code typically should be idiomatic, and these styles are
not idiomatic Python (for better or worse).

Paul


More information about the Python-ideas mailing list