[Python-Dev] Re: PEP 279 (original) (raw)
Just van Rossum just@letterror.com
Fri, 29 Mar 2002 09:01:11 +0100
- Previous message: [Python-Dev] Re: PEP 279
- Next message: [Python-Dev] Re: PEP 279
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Raymond Hettinger wrote:
I like itercount() or enumerate(). The reason is that this function can work with any iterable including those that do not have numeric indices (such as dictionaries). Counting or enumeration is what is really happening.
But the reason for this proposal is to turn this idiom:
for i in range(len(seq)): element = seq[i] ...
into this:
for i, element in enumerate(seq): ...
It's hardly useful for types that don't have numeric indices, so the fact that it does work with any iterator seems almost an implementation detail.
I quite like the name enumerate. Hate itercount. I'm neutral on indexed.
Just
- Previous message: [Python-Dev] Re: PEP 279
- Next message: [Python-Dev] Re: PEP 279
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]