On Sat, Apr 11, 2020 at 7:41 AM Elliott Dehnbostel
Thanks. How do I go explore the archives?
They're available from the Mailman page linked in the footer: https://mail.python.org/mailman3/lists/python-ideas.python.org/ You might have to do some digging, as the words "filter" and "list" will come up quite a lot, but the results will be quite informative.
I think the spirit of this is along the following line:
for(int i = 0; (cond); i++) ... Is a common way to a express a loop breaking out once a condition is not met, as is true for:
while cond
But there is no way to express (in terse fashion) a loop in which a condition is true but does not break if it is not satisfied. That's normally expressed by nesting an 'if' statement but by doing this, the 'for' and 'if' appear as separate when really the 'if' could be considered as part of the definition of the loop itself.
Right, I absolutely agree. Logically, you're combining a loop with a condition. In a comprehension, that can be done easily and cleanly; but in the statement form, it requires an additional indentation level. One neat trick, though, is to invert the condition. If you have a lot of code that would be guarded by "if cond:", you can instead write "if not cond: continue" and then proceed with the code from there. The main block of code doesn't get indented inside the 'if' (because it isn't inside it), but it's still guarded by the same condition (since the loop body will be skipped completely). ChrisA