[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-29 Thread Raimi bin Karim
Steven D'Aprano wrote: > Does anyone know what builtin or stdlib objects iterators fail to > implement `__iter__`? I haven't been able to find any -- all the obvious > examples do (map, filter, reversed, zip, generators, list iterators, > set iterators, etc). Could it possibly be... the async it

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-28 Thread Raimi bin Karim
Hi Evpok, Evpok Padding wrote: > Hi, > All apologies if it has been clarified earlier, but if you dislike nested > method calls what is wrong with operating on generators as in No worries! I think the theme of this discussion is using idioms from map, reduce + functions from itertools module them

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-28 Thread Raimi bin Karim
Hi Stephen, Stephen J. Turnbull wrote: > 1. Is dataflow/fluent programming distinguishable from whatever it > was that Guido didn't like about method chaining idioms? If so, > how? Are you referring to this https://mail.python.org/pipermail/python-dev/2003-October/038855.html? He mentio

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Raimi bin Karim
> > But I guess since method chaining (for collection pipeline) is more > > commonplace across many languages, it might be easier to catch on. > We should be careful about the terminology. Method chaining and > pipelining are related, but independent, design patterns or idioms: Noted and thank yo

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Raimi bin Karim
> To me, the most natural syntax looks like this: > value | function *args, **kwargs > equivalent to `function(value, *args, **kwargs)` but of course we've > already used the pipe for bitwise-or and set intersection. `>>` would be > another equally good operator. I don't really like `|>` as an op

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Raimi bin Karim
> I'm somewhat ambivalent about this pattern. Sometimes I find it > readable and natural, other times it doesn't fit my intuition for the > problem domain. Like any other pattern, you don't have to subscribe to it and use it to solve every problem. A pattern is just another tool in your toolbox tha

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-26 Thread Raimi bin Karim
(Fyi I am both 'Remy' and 'Raimi bin Karim', I don't know how that happened). 📌Goal Based on the discussion in the past few days, I’d like to circle back to my first post to refine the goal of this proposal: to improve readability of chaining lazy functions (map, fi

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Raimi bin Karim
> Function and method chaining. > Procedural/function syntax for chains of function calls suck. It is too > verbose (heavy on parentheses) and written backwards: > print(sort(filter(transform(merge(extract(data)), args To be honest, I think _this_ is the problem that I was trying to address, w

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Raimi bin Karim
Hi Steve, > Reviving old threads from a decade ago is fine, if something has > changed. Otherwise we're likely to just going to repeat the same things > that were said a decade ago. > Has anything changed in that time? The theme for previous thread (https://mail.python.org/archives/list/pytho

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Raimi bin Karim
> This would place a burden on all iterators to implement a large > and complex interface. This goes directly against the philosophy of > Python protocols, which is to be as minimal as possible. Do one thing, > and do it well. Agreed. > And where do you stop? You've picked an arbitrary subset of t

[Python-ideas] Re: Enhancing iterator objects with map, filter, reduce methods

2021-11-22 Thread Raimi bin Karim
> It's not too hard to create your own dataflow class if you want one. > It can start with any arbitrary iterable, and then have your map and > filter methods just the same. Cool trick: you can even call your class > iter! :) > class iter: > _get_iterator = iter # snapshot the original > de