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.bka...@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
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QKV2QNBFICYGYI7Z3PQLWI76Q25VZSQ7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to