[Python-ideas] Consider making enumerate a sequence if its argument is a sequence
Paul Moore
p.f.moore at gmail.com
Thu Oct 1 22:11:58 CEST 2015
On 1 October 2015 at 19:41, Random832 <random832 at fastmail.com> wrote:
> On Thu, Oct 1, 2015, at 14:29, Chris Barker wrote:
>> But if why do you need to know that something is an iterable, but NOT an
>> iterator? isn't that an implementation detail?
>
> Because an iterator *cannot possibly* allow you to loop through the
> contents twice [either one after the other or in parallel], whereas
> *most* non-iterator iterables do allow this. This (among other things
> such as representing a well-defined finite bag of values) is the
> property we're really chasing, "non-iterator iterable" is just a clumsy
> and inaccurate way of saying it.
If I understand what you mean by "non-iterator iterable", then a long
time ago, there was a similar discussion and the term "reiterable" was
used (Google will probably find references). Nothing ever came of the
discussion - if I recall, there was a lot of theoretical debate, but
few practical use cases.
Anyone wanting to avoid a long, inconclusive discussion should
probably chase up that old thread and see if anything new has been
added this time around :-)
Paul
More information about the Python-ideas
mailing list