l = range(int(1E9))

Chris Angelico rosuav at gmail.com
Sun May 3 06:59:54 EDT 2015


On Sun, May 3, 2015 at 8:32 PM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> scripting
> languages often lack a C-style for-loop, using a foreach loop instead. E.g.
> I believe the canonical way to loop in bash is something like:
>
>     for $i in `seq start stop` do ...
>
> (by memory).

Newer versions of bash have grown an alternative syntax for that
common case, but if you need to support older forms, or other shells,
then yes, it's something like that. Maybe without the dollar sign. (I
can never remember the exact syntax, and I know bash is really finicky
about where you put newlines and where you don't, but it looks
something like what you had.)

ChrisA



More information about the Python-list mailing list