[Python-ideas] More classical for-loop

Steven D'Aprano steve at pearwood.info
Fri Feb 17 23:43:26 EST 2017


On Fri, Feb 17, 2017 at 06:31:19PM +0100, Mikhail V wrote:

> I have said I need the index, probably you've misread my last comment.
> Further more I explained why I think iteration over index should be the
> preferred way, it help with readability a lot.

Your concept of readability is clearly radically different from that of 
the majority of the Python community.


> All my learning years ended up with rewriting most code to "for i in
> range()"

How do you cope with generators and iterators that don't have a length?

How do you cope with iterables which are infinite?


> and I slap myself when I start to write "for e in L".
> It is exactly where TOOWTDI applies perfectly and it is integer iteration
> for me.

It sounds like Python is not a good match for the way you think. I don't 
say that as a put-down, but perhaps you would be happier if you found 
another language that works the way you would like, instead of trying to 
force Python to be something it isn't?



-- 
Steve


More information about the Python-ideas mailing list