On Thu, Oct 1, 2015 at 11:41 AM, Random832 <random832@fastmail.com> 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.

um, then shod;nt you simply describe the iterator as an iterator?

so any "iterable" would be assumed to be a non-iterator iterable.

I guess this all comes about because we don't want to have to write this:

for i in iter(an_iterable):

i.e have a different interface for interable and an iterable 

but I'm still lost on when tha all has to be spelled out...

And back the original question, for enumerate:

OK, you can't really have it e both an iterator AND a sequence, but couldn't it be an iterator and support indexing?

Though I'm starting to wonder about the use case:

enumerate() is a way to get the items in an iterable and an index at the same time -- so if you want to pass in a sequence, and index the result, why not just index into the sequence in the first place??



Christopher Barker, Ph.D.

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception