Thoughts on PEP284

David Eppstein eppstein at ics.uci.edu
Tue Sep 23 00:53:15 EDT 2003


In article <m2eky8dtny.fsf at mycroft.actrix.gen.nz>,
 Paul Foley <see at below.invalid> wrote:

> > There may be some hint towards PEP284 (integer for loops) in a review
> > of ideas from other languages, but I'm damned if i can figure it out.
> > I spent some time thinking about it and couldn't find anything that
> > would cover the issue.
> 
> > All I came up with was the recognition that some other languages have
> > 'for' and 'foreach' loops. But Python went down the route of using
> > 'for' for looping over lists/iterators a long time ago. Maybe a new
> > keyword or combination could help, such as...
> 
> >   for range i in 0 <= i < 10 :

The idea behind the specific syntax of PEP284 was simply the following 
observation: one way of reading "for i in iterator" is that it loops 
over the values for which the expression "i in iterator" is true.
What types of expressions other than the "in" operator could be 
substituted in the same context and do something useful?

-- 
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