[Python-ideas] Consider making enumerate a sequence if its argument is a sequence
Chris Barker
chris.barker at noaa.gov
Wed Sep 30 19:47:29 CEST 2015
On Wed, Sep 30, 2015 at 10:33 AM, 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')]
well, that's because zip is using the same iterator it two places. would
that ever be the case with enumerate?
-CHB
>
>
> _______________________________________________
> 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/
>
--
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/20150930/9aaeda2a/attachment.html>
More information about the Python-ideas
mailing list