Thoughts on PEP284

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Tue Sep 23 01:30:07 EDT 2003


On Mon, 22 Sep 2003 21:53:15 -0700, David Eppstein
<eppstein at ics.uci.edu> wrote:

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

OK - that makes sense, but I don't think I'd naturally read '0 <= i <
10' as an iterator without a good deal of prompting. Even with the
explanation, I still feel the need for a different (or extra) keyword
to emphasise the difference.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list