
On Mon, Nov 29, 2021 at 5:54 AM Christopher Barker <pythonchb@gmail.com> wrote:
On Sun, Nov 28, 2021 at 9:30 AM Evpok Padding <evpok.padding@gmail.com> wrote:
All apologies if it has been clarified earlier, but if you dislike nested method calls what is wrong with operating on generators as in
```pycon
itr = (i**2 for i in range(8)) itr = (i-1 for i in itr if i > 0) list(itr) [0, 3, 8, 15, 24, 35, 48]
+1 -- what I don't like about itertools is that it's not comprehension friendly. I'm still confused a bit about this:
Back in the day Python had map, filter, and reduce.
Then comprehensions were added, which are another way to express map and filter in one go.
I really like comprehensions.
But since then, there has been an informal movement, if you can call it that, back to map and filter. Itertools is great, but it's not all that compatible with comprehensions :-(
Citation needed? What informal movement has there been, and where? The only problem with itertools and comprehensions is that you get code written in two different ways. I don't recall seeing anyone say "don't use a comprehension if you're going to then use itertools.tee on it" or anything like that. Maybe I just don't hang out in the right places? ChrisA