[Python-ideas] Introduce collections.Reiterable
Andrew Barnert
abarnert at yahoo.com
Sun Sep 22 13:57:03 CEST 2013
On Sep 22, 2013, at 3:55, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Sep 22, 2013 at 10:58:40AM +0200, Georg Brandl wrote:
>
>>> Or you could just use the existing terminology and talk about
>>> iterables vs iterators instead of inventing your own terms.
>>
>> Ack. Please don't create new terms, rather suggest an improvement to the
>> glossary definition if you think it's inadequate.
>
> I'm not inventing new terminology. I'm using the plain English meanings
> of "directly" and "indirectly", and the standard meaning of "iterate",
> "iterator", "iterable" as used by Python and described in the glossary.
No you aren't. You're using iterable as a synonym for iterator, which is not how it's used by Python or described in the glossary.
> As the glossary says, "The for statement [calls iter] for you, creating
> a TEMPORARY UNNAMED VARIABLE to hold the iterator for the duration of
> the loop." [emphasis added] All I am doing is distinguishing between the
> iterable object that the for-loop calls iter() on, which need not have a
> __next__ method, and the iterable object that the for-loop calls
> __next__ on. They're not always the same object.
This is precisely the distinction between iterables and iterators.
The object that the for loop calls iter on is an iterable.
The object that the for loop gets back from that iter call, binds a temporary unnamed variable to, and calls __next__ on is an iterator.
> But as I've already said, the distinction usually doesn't matter.
Yes it does. This is a very important distinction. That's why Python already has separate terminology. And separate ABCs.
More information about the Python-ideas
mailing list