[Python-ideas] Consider making enumerate a sequence if its argument is a sequence
Serhiy Storchaka
storchaka at gmail.com
Wed Sep 30 19:33:05 CEST 2015
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')]
More information about the Python-ideas
mailing list