
On 11/26/2021 1:59 PM, Christopher Barker wrote:
Just a note here: On Fri, Nov 26, 2021 at 6:37 AM Raimi bin Karim <raimi.bkarim@gmail.com> wrote:
to improve readability of chaining lazy functions (map, filter, etc.) for iterables.
I think there is a slight misperception here. I've seen the term lazy used a couple times, and at least once in contrast to list comprehensions. However, there are, of course, generator comprehensions (AKA generator expressions) which are also lazy.
So this is about syntax, not capability.
Another note: I'm not recommending it, but we could add a bunch of things to the Iterator ABC, and then it could be available everywhere.
Is that true? I'm genuinely curious. I have lots of code with is the logical equivalent of: class Foo: def __init__(self, s): self.s = s self.idx = -1 def __iter__(self): return self def __next__(self): self.idx += 1 if self.idx < len(self.s): return self.s[self.idx] raise StopIteration() Would adding something to the Iterator ABC really also add it to my class Foo? Eric