[Python-ideas] Consider making enumerate a sequence if its argument is a sequence

Sven R. Kunze srkunze at mail.de
Thu Oct 1 20:38:45 CEST 2015


On 01.10.2015 20:29, Chris Barker wrote:
> On Thu, Oct 1, 2015 at 8:10 AM, Steven D'Aprano <steve at pearwood.info 
> <mailto:steve at pearwood.info>> wrote:
>
>      But there
>     is a *general* distinction between two cases:
>
>     - iterables which are iterators
>     - iterables which are not iterators
>
>     We have a name for the first set: "iterators". But we don't have a
>     name
>     for the second set. Andrew suggested "non-iterator iterables" is too
>     clumsy for general use, and suggests we need a better name. You
>     suggested "iterables", but that clearly cannot work, since
>     iterators are
>     a kind of iterable.
>
>
> sure -- but I've lost track of why it matters. "iterator" is well 
> defined. And so is "iterable" -- why do we need to care whether the 
> iterable returns itself when asked for an iterator?
>
> the term "sequence" is useful -- it defines certain behavior. So is 
> the term "iterable", for the same reason.
>
> And it would be useful to say that given object is both a sequence and 
> an iterable (are sequences iterable by definition?)
>
> But if why do you need to know that something is an iterable, but NOT 
> an iterator? isn't that an implementation detail?

You say some terms are useful because they define certain behavior.

I don't question this, but what I find questionable is the proliferation 
of all this equally-sounding and -feeling concepts. Your reaction 
supports that observation.


Best,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151001/931b2bbd/attachment.html>


More information about the Python-ideas mailing list