for-else

Jeffrey Barish jeff_barish at earthlink.net
Mon Mar 10 12:05:19 EDT 2008


egbert wrote:

> The idea of the if-else is:
> .  depending on some condition either do this or do something else,
> .  don't do them both.

Indubitably, this statement is correct for other programming languages.  I
was initially surprised by loop-else when learning Python because I
approached these constructs from the perspective of other programming
languages I knew, as you are doing.  Before rejecting the Python
constructs, I asked myself whether the application of a different idea
resulted in a consistent, sensible interpretation.  The key is to ask not
whether the Python constructs fit a particular idea of if-else and
loop-else, but whether a reasonable idea exists within which the Python
constructs make sense.  For me and others in this thread, it does. 
Different keywords would, no doubt, result in constructs that fit other
ideas better, but personally I am content with the current solution.
-- 
Jeffrey Barish




More information about the Python-list mailing list