I like this proposal from a book-keeping perspective... the interface provided by sequences/mappings/sets is definitely different than the interface provided by generic iterables (mostly due to the fact that the former group can be iterated repeatedly).

With that said, I'm not really sure what how the `Reiterable` (or whatever suitable name the smart people around here come up with) class would be implemented.

    class Reiterable(Iterable):

This seems a bit weird.  All of the other ABCs make some guarantees.  If I fill out a set of methods then my object will be a <fill in ABC>.  There doesn't seem to be a set of methods that exist to distinguish between an object that is Iterable and an object that is Reiterable.

I suppose that the counter argument is that we always assume that the methods on the object are implemented "reasonably".  Perhaps the main goal for this class is just book-keeping/annotating/loose "if you say so" typechecking and we're trusting that if someone subclasses `Reiterable`, they're going to implement it in such a way that it indeed can be iterated multiple times and that they didn't just mean `Iterable`.  If that's the intent, I think that is also fine with me -- it just seemed like someone ought to mention it once...

On Thu, Jul 21, 2016 at 5:29 PM, Guido van Rossum <guido@python.org> wrote:
On Thu, Jul 21, 2016 at 5:05 PM, Thomas Nyberg <tomuxiong@gmail.com> wrote:
> On 07/21/2016 07:58 PM, Guido van Rossum wrote:
>> But there's already Container which means "supports __contains__".
>> Collection might cause confusing with the module name collections.
>> Otherwise either would be a good candidate...
> Coming out of lurking...
> StaticIterable? ConstIterable? Something to indicate that if you just
> iterate over it you keep getting the same thing?

Neither "static" nor "const" convey the right meaning.

> Personally I think Reiterable is about as clear as it ever will be...

Yeah, I think that's my conclusion as well.

--Guido van Rossum (python.org/~guido)
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/




E: matt@getpattern.com // P: 603.892.7736

We’re looking for beta testers.  Go here to sign up!