why I don't like range/xrange

Neil Cerutti horpner at yahoo.com
Fri Feb 16 14:41:36 EST 2007


On 2007-02-16, Bart Ogryczak <B.Ogryczak at gmail.com> wrote:
> On Feb 16, 4:30 pm, "stdazi" <std... at gmail.com> wrote:
>
>> for (i = 0; some_function() /* or other condition */ ; i++)
>
> C's "for(pre,cond,post) code" is nothing more, then shorthand form of
> "pre; while(cond) {code; post;}"
> Which translated to Python would be:
>
> pre
> while cond:
>   code
>   post

No, when you consider the continue statement, which which Python
also supports.

for (pre; cond; post) {
  continue;
}

That's not an infinite loop in C, but the Python while-loop
version would be.

-- 
Neil Cerutti



More information about the Python-list mailing list