for / while else doesn't make sense

Steven D'Aprano steve at pearwood.info
Sat May 21 07:26:49 EDT 2016


On Sat, 21 May 2016 09:57 am, Dennis Lee Bieber wrote:

> On Fri, 20 May 2016 11:55:34 -0000 (UTC), Jon Ribbens
> <jon+usenet at unequivocal.co.uk> declaimed the following:
> 
>>
>>I would find that very confusing. "then:" makes it sound like
>>executing that block is the usual case, when in practice it is
>>usually the exception - the fallback code if the expected value
>>was not found.
> 
> And I'll second that...
> 
> In those languages that use "then" as a keyword, it separates the "if"
> conditional from the "true" block of code. Or -- visualize replacing the
> ":" on the "for" with the word "then"
> 
> for x in sequence then
> do stuff with x
> else
> do something with no x
> 
> 
> If a different keyword is to be introduced, I nominate "otherwise"

"otherwise" fails for the same reason that "else" fails: it suggests that
the else block is an alternative to the for block, which is exactly what it
is NOT.




-- 
Steven




More information about the Python-list mailing list