> However I'm struggling to find a use case for the python for-else definition where you don't end up doing something like 'result=something; break' anyway. What would be the point of breaking if you don't have any results? And if you have such a situation, wouldn't an exception make more sense?
This is also useful for an accumulator and sentinel case. Say you're parsing a file and need to grab a null-terminated string:
result = ''
for b in file_bytes_iterator:
if b == '\0': break
result += b
else:
throw ValueError("String is unterminated")
result will contain the parsed string, and file_bytes_iterator will be ready to return the first byte after the terminator, to continue parsing the file