
April 1, 2022
6:40 a.m.
+1 Python has always seemed to me to allow one to completely describe exactly what you are iterating over in a for loop in the one line containing the for statement. And that is more or less the principle I tend to follow, unless the for statement simply gets to be too long. I have even used the `for item in (item for item in items if ... ):`, although this is sometimes too much of a brainflick to be worth it. I have also used (on separate lines) `subset = (item for item in items if ...); for item in subset:`, but if for...in...if syntax ever became available, I'd wear it out.