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?



Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/


Christopher Barker, Ph.D.

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