<div dir="ltr">This is a bit of a tangent, hopefully convergent, but hey, this is python-ideas:<div><br></div><div>Would there be interest in some kind of method/API for restarting iterators? If there was a it.restart() (or reset(it)), it would probably be a good idea to name the concept in the same way as the method ( "Restartable" or "Resettable"). And having that as an actual protocol would simplify the discussion on both what the type should contain and how it should be named, while having actal applications to simplify code (and reduce memory usage in cases when creating a list is not needed, just making multiple passes).</div><div><br></div><div>I'm not proposing one of those names in particular, discussing whether this concept makes sense and is useful should be before the naming</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 22, 2016 at 3:44 AM, Stephan Hoyer <span dir="ltr"><<a href="mailto:shoyer@gmail.com" target="_blank">shoyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Thu, Jul 21, 2016 at 9:04 PM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If it really must be two words, how about SizedIterable? That suggests<br>
it's a subclass of Sized and Iterable, which it is. Container doesn't<br>
need separate mention, it's pretty obvious that any Iterable can<br>
implement __contains__, and more people know that Iterable is an ABC<br>
than Container.</blockquote><div><br></div></span><div>In my experiments with type annotations, we recently encountered this exact same issue (variables for which either sets or lists should be valid). My initial solution was almost exactly what you propose here: we wrote a SizedIterable class, simply inheriting from Sized and Iterable.</div><div><br></div><div>Ultimately, we didn't find this very satisfying, because we realized that strings are SizedIterables (they're sequences, too), and we really didn't want to allow accidentally passing strings that would be interpreted as iterables of characters. Unfortunately, I don't think there's any good way in Python to specify "any sized iterable that isn't a string".</div></div></div></div>
<br>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Daniel F. Moisset - <span style="font-size:small">UK Country Manager</span><div><a href="http://www.machinalis.com" target="_blank">www.machinalis.com</a></div><div>Skype: @dmoisset</div></div></div></div></div>
</div>