On Jun 12, 7:55 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 12 Jun 2007 10:41:28 -0300, Chris Mellon <[EMAIL PROTECTED]> > escribió: > > > > > On 6/12/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > >> for x in iterable: > >> do something with x > >> else: > >> do something when there are no more x > > >> You can think the above as: > > >> while there are still values in iterable: > >> do something with the next value > >> else: > >> do something when there are no more items > > > This is a good way of phrasing it and I hope I can remember it, > > because for..else always gives me trouble. To me, "else" indicates the > > negative condition and I intuitively associate it with executing the > > loop early, not normal exit. Personally, I think a different keyword > > (maybe "after"?) would have done a better job of clarifying this. > > Yes, maybe, but it's hard to find a keyword equally applicable to "for" > and "while" and creating two new keywords for essencially the same thing > would be too much... Anyway it's too late to be changed now. > > -- > Gabriel Genellina
Hmmm, Would replacing the word 'else' with 'then' read better? The implied meaning is if the loop terminates normally *then* also do this block. - Paddy.
-- http://mail.python.org/mailman/listinfo/python-list