I understood that _iterables_ are required to have an __iter__ method, not iterators.Therefore, are we simply discussing whether all iterators should be iterable?
At the moment the CPython implementation does't require that AFAIK.
regardsSteve_______________________________________________On Tue, Sep 14, 2021 at 8:39 PM Guido van Rossum <guido@python.org> wrote:My view of this is:A. It's not an iterator if it doesn't define `__next__`.B. It is strongly recommended that iterators also define `__iter__`.In "standards" language, I think (A) is MUST and (B) is merely OUGHT or maybe SHOULD.On Tue, Sep 14, 2021 at 12:30 PM Brett Cannon <brett@python.org> wrote:_______________________________________________Over in https://github.com/python/typeshed/issues/6030 I have managed to kick up a discussion over what exactly an "iterator" is. If you look at https://docs.python.org/3/library/functions.html#iter you will see the docs say it "Return[s] an iterator object." Great, but you go the glossary definition of "iterator" at https://docs.python.org/3/glossary.html#term-iterator you will see it says "[i]terators are required to have an__iter__()
method" which neither `for` nor `iter()` actually enforce.Is there something to do here? Do we loosen the definition of "iterator" to say they should define __iter__? Leave it as-is with an understanding that we know that it's technically inaccurate for iter() but that we want to encourage people to define __iter__? I'm assuming people don't want to change `for` and `iter()` to start requiring __iter__ be defined if we decided to go down the "remove the __aiter__ requirement" from aiter() last week.BTW all of this applies to async iterators as well.
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/3W7TDX5KNVQVGT5CUHBK33M7VNTP25DZ/
Code of Conduct: http://python.org/psf/codeofconduct/
--_______________________________________________--Guido van Rossum (python.org/~guido)Pronouns: he/him (why is my pronoun here?)
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/OICGRBPLXO6WXO4CHTGUK46WIHO7PDUU/
Code of Conduct: http://python.org/psf/codeofconduct/
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-leave@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/KHDMNMW6XEPYOZ5AQ22AN6YTN2POMHQE/
Code of Conduct: http://python.org/psf/codeofconduct/