On Wed, Sep 30, 2015 at 10:33 AM, Serhiy Storchaka <storchaka@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@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@noaa.gov