"for" with "else"?

Andrew Dalke adalke at mindspring.com
Tue Sep 30 23:38:51 EDT 2003


John Roth:
> I don't see what exceptions have to do with it. There are three
> special ending cases: with break, empty sequence and sequence
> exhausted. Empty sequence is the only one that isn't handled easily.

Could you give an example of when you would actually use an
'empty_sequence' in the real world?  It's never been a problem
for me (that I can recall) where that distinction was important.

> What I'd like to see is a more general exit clause that also
> applies to the while statement. Something like:
>
> on break:
> on normal_exit:
> on empty_sequence:
> on body_not_executed:

Aren't 'empty_sequence' and 'body_not_executed' identical?

Could you give examples using each one?

What about code which uses a return in the block?  Is
that counted under 'break'?  What about raising an exception?

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list