Is using range() in for loops really Pythonic?

Dave Parker daveparker at flamingthunder.com
Tue May 13 09:14:34 EDT 2008


>         REXX's loop construct subsumes all the common uses... And worse, it
> appears that a repetition and a condition can be part of the single
> statement.

Thank you for pointing out the REXX examples.  I am a Kedit user, but
had forgotten about the REXX do-loops.  I'll keep them in mind when I
add an easy way to "do this n times" to Flaming Thunder this weekend.

On May 11, 8:53 pm, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Mon, 12 May 2008 00:43:08 GMT, Jonathsn Cronin <j... at theworld.com>
> declaimed the following in comp.lang.python:
>
> > I agree in principle; the first is iteration and the second is repetition.
> > In Python, the common idiom for a fixed number of repetitions is iterating
> > over a number range.  This is true in most languages I am familiar with,
> > probably because fixed repetition, where you don't care about the "index"
> > value, is rarely used.
>
> > The only language I've used that does have fixed repetition is an (old)
> > dialect of lisp, and I'm not sure it even made it into Common Lisp.  
> > Smalltalk and Ruby do have fixed repetition.
>
>         REXX's loop construct subsumes all the common uses... And worse, it
> appears that a repetition and a condition can be part of the single
> statement.
>
> DO FOREVER
> ...
> END
>
> DO repeatcount
> ...
> END
>
> DO loopvar=first TO last BY step FOR reptcount
> ...
> END
>
> (where "TO last", "BY step", "FOR reptcount" are all optional clauses!)
>
> DO WHILE conditional
> ...
> END
>
> DO UNTIL conditional
> ...
> END
>
>         Mixing modes
>
> DO loopvar=first BY step UNTIL conditional
> ...
> END
>
> Hmmm, looks like it's been extended for container objects (those that
> support MAKEARRAY):
>
> DO item OVER container
> ...
> END
> --
>         Wulfraed        Dennis Lee Bieber               KD6MOG
>         wlfr... at ix.netcom.com              wulfr... at bestiaria.com
>                 HTTP://wlfraed.home.netcom.com/
>         (Bestiaria Support Staff:               web-a... at bestiaria.com)
>                 HTTP://www.bestiaria.com/




More information about the Python-list mailing list