[Python-ideas] Consider making enumerate a sequence if its argument is a sequence
mal at egenix.com
Wed Sep 30 20:11:00 CEST 2015
On 30.09.2015 19:19, Neil Girdhar wrote:
> I guess, I'm just asking for enumerate to go through the same change that
> range went through. Why wasn't it a problem for range?
range() returns a list in Python 2 and a generator in Python 3.
enumerate() has never returned a sequence. It was one
of the first builtin APIs in Python to return a generator:
after iterators and generators were introduced to the language:
The main purpose of enumerate() is to allow enumeration of
objects in a sequence or other iterable. If you need a sequence,
simply wrap it with list(), e.g. list(enumerate(sequence)).
Professional Python Services directly from the Experts (#1, Sep 30 2015)
>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>> Python Database Interfaces ... http://products.egenix.com/
>>> Plone/Zope Database Interfaces ... http://zope.egenix.com/
2015-09-25: Started a Python blog ... ... http://malemburg.com/
2015-10-21: Python Meeting Duesseldorf ... 21 days to go
::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-ideas