2 Jan
2013
2 Jan
'13
9:37 a.m.
On Wed, Jan 2, 2013 at 8:27 PM, Steven D'Aprano
There would be a lot less confusion if they weren't called "else". Even now, I have to explicitly remind myself that the else block doesn't run if the for loop is empty, but *after* the for block.
# Python 4000 proposal: for x in seq: ... then: # this is skipped by a break else: # this runs only if seq is empty
Calling it "else" makes perfect sense if you're searching for something. for x in lst: if x.is_what_we_want(): break else: x=thing() lst.append(x) ChrisA