PEP 284, Integer for-loops

Greg Ewing greg at cosc.canterbury.ac.nz
Wed Mar 6 22:09:47 EST 2002


"Delaney, Timothy" wrote:
> 
> without being a general solution (no step ...

To me, the lack of a step is a *feature*, not a bug!

Steps other than 1 in a range are confusing when
you don't land exactly on the endpoints. Which
endpoint do you miss? Do you even hit either of
them? And it's even worse when the step is negative.
Do the endpoints swap over? Does the closed/open
status of the endpoints swap over? Do you miss
the opposite endpoint if the step isn't -1?
Etc.

So, I see *considerable* benefit from eliminating
this degree of freedom from the range generation
itself, and making the programmer be explicit on
how to map a step-1 range onto something else if
needed.

Perhaps this comment could be added to the PEP?

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list