[Python-Dev] PEP 276 (simple iterator for ints)

Nick Coghlan ncoghlan at iinet.net.au
Thu Jul 1 00:24:08 EDT 2004


Greg Ewing wrote:

> "Chermside, Michael" <mchermside at ingdirect.com>:
> 
> 
>>    >>> for i in len(myList):
>>    ...     doSomethingWithIndexes(i)
>>
>>is simple and elegant.
> 
> 
> IMO it would be clearer, and equally elegant, to write
> this as something like
> 
>   for i in indices(myList):
>     ...
> 
> which is easily accomplished with the aid of a suitable
> definition for indices(). No language changes needed.

And I believe most of those use cases are better covered by enumerate() 
anyway.

Interesting that in the course of this discussion I've gone from 'nice 
idea' to 'no way!'

Cheers,
Nick.

-- 
Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268



More information about the Python-Dev mailing list