Inspiration and influence of the else clause of loop statements?
- by Aristide
Python offers an optional loop-else clause which is executed if and only if the loop is not terminated by a break. (In other words, the condition fails for a while-loop or the iterator is exhausted for a for-loop.)
Does this loop-else construct originate from another language? (Either theoretical or actually implemented.) Has it been taken up in any newer language?
Maybe I should ask the former of Guido, but surely he is too busy for such a futile inquiry. ;-)
Related discussion and examples:
Pythonic ways to use ‘else’ in a for loop