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

Chris Barker chris.barker at noaa.gov
Thu Oct 1 20:29:51 CEST 2015


On Thu, Oct 1, 2015 at 8:10 AM, Steven D'Aprano <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?

-CHB


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151001/02b84b69/attachment.html>


More information about the Python-ideas mailing list