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. (I'm actually moderately disappointed, incidentally, that there's no easy way to create e.g. an iterable that will spin up a fresh copy of the same generator each time it's called. But it's easy enough to make a decorator for that.)