Thoughts on PEP284

David Eppstein eppstein at ics.uci.edu
Tue Sep 23 06:00:32 CEST 2003


In article <SnObb.1581$PT3.257319 at news20.bellglobal.com>,
 "Sean Ross" <sross at connectmail.carleton.ca> wrote:

> > Some more looping thoughts - this time on integer for loops...
> 
> Hi.
> How about the following:
> 
> for i in 0...10:
>     # suite
> 
> where 0...10 works something like xrange(10).

I can't find the message you're replying to, so am responding here only 
to yours.

I personally am uninterested in an integer for-loop syntax that is 
limited to the unintuitiveness of range and xrange's arguments -- 
they're great for looping forwards through the indices into a list, not 
so great for almost anything else.  If that's all the loop syntax can 
do, why not just keep the current "for i in range(10):" syntax?  
"Explicit is better than implicit."

But anyway, PEP 284 has been kind of moribund since Guido dissed it in 
his Parade of PEPs.  I'm not sure what (if anything) it would take to 
revive it, but convoluted syntax like "for i in 0...10.by(2):" is 
probably not it.  "for i in 0:10:2:" would be more Pythonic, but has a 
little ambiguity problem ("for i in 0:10:2" without the colon seems like 
it should execute the statement "2" ten times) and again doesn't add 
much in readability or power to what we can already do with range.

-- 
David Eppstein                      http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science




More information about the Python-list mailing list