for / while else doesn't make sense

Lawrence D’Oliveiro lawrencedo99 at gmail.com
Fri Jun 3 12:24:31 EDT 2016


On Saturday, June 4, 2016 at 3:52:42 AM UTC+12, Rob Gaddi wrote:
> Lawrence D’Oliveiro wrote:
> 
>> The reason why I don’t like this is that there are two ways out of the
>> Python for-statement, and they are written quite differently. Why the
>> asymmetry? Logically, all ways out of a loop are of equal significance.
> 
> I wouldn't say that at all.  One is early termination due to success. 
> The other is that you've run out of things to try, and exit due to
> exhaustion of the iterator.  They're two very different cases...

Different in what way? A loop exit is a loop exit. It causes termination of the loop.



More information about the Python-list mailing list