[Python-ideas] An ABC representing "Iterable, Sized, Container"
matt at getpattern.com
Fri Jul 22 02:38:15 EDT 2016
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
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 at python.org> wrote:
> On Thu, Jul 21, 2016 at 5:05 PM, Thomas Nyberg <tomuxiong at gmail.com>
> > 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
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
Matt Gilson // SOFTWARE ENGINEER
E: matt at getpattern.com // P: 603.892.7736
We’re looking for beta testers. Go here
<https://www.getpattern.com/meetpattern> to sign up!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas