newbie question

Dan Perl danperl at rogers.com
Thu Feb 10 09:38:12 EST 2005


"Peter Hansen" <peter at engcorp.com> wrote in message 
news:dsWdnSiaAL8u9JbfRVn-sg at powergate.ca...
> Dan Perl wrote:
>> OTOH, I was thinking of saying in my previous posting that I prefer
>>     for n in range(start, 0, -1):
>> to
>>     n = start
>>     while (n--)
>> I think that the first form is more readable, although that may be just 
>> me. I would actually even prefer the 'for' statement in C to the 'while' 
>> statement:
>>     for (n=start; n<=0; n--)
>
> I'm not sure if it's just picking nits, but I'd like to
> point out that neither of your alternatives is actually
> equivalent to the while (n--) form...  nor was Jeff
> Shannon's attempt (in that case it leaves the loop with
> n equal to 0, not -1).

You're right in your nit picking.  I have to go back to using some C/C++ and 
Java also, I don't want to forget them completely. 





More information about the Python-list mailing list