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

Neil Girdhar mistersheik at gmail.com
Wed Sep 30 20:10:33 CEST 2015


Ah, that's a great point.  Thanks.  I guess range was never an Iterator,
which is a key difference.

On Wed, Sep 30, 2015 at 1:33 PM Serhiy Storchaka <storchaka at gmail.com>
wrote:

> On 30.09.15 20:18, Neil Girdhar wrote:
> > Ah good point.  Well, in the case of a sequence argument, an enumerate
> > object could be both a sequence and an iterator.
>
> It can't be.
>
> For sequence:
>
>  >>> x = 'abcd'
>  >>> list(zip(x, x))
> [('a', 'a'), ('b', 'b'), ('c', 'c'), ('d', 'd')]
>
> For iterator:
>
>  >>> x = iter('abcd')
>  >>> list(zip(x, x))
> [('a', 'b'), ('c', 'd')]
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/python-ideas/x1omibxxcMw/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150930/3a0a4214/attachment.html>


More information about the Python-ideas mailing list