[Python-ideas] try-else without except or finally

Matt Joiner anacrolix at gmail.com
Mon Nov 14 22:24:06 CET 2011


well for all cases bar the if/else, "else" is used more like a "then".

for/then, while/then, try/except/then/finally

On Tue, Nov 15, 2011 at 7:23 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Chris Kaynor wrote:
>>
>> While it is redundant to allow else without except, I would agree that
>> it should be allowed for the same reason that else is allowed on for
>> and while without a break. The alternative would be to make the later
>> illegal. Either seems reasonable, however the former maintains
>> backwards compatibility, while the later breaks it.
>
> if / else: if the 'if' condition is False, run the 'else'
>
> for / else: when the 'for' condition is False, run the 'else'
>
> while / else: when the 'while' condition is False, run the 'else'
>
> try /except / else: when the 'except' condition is False, run the 'else'
>
> try / else: when the 'try' condition is False, run the 'else' ??
>
> To be consistent, the 'else' in a try/else would basically be an 'except
> Exception' -- it completely reverses the meaning of the 'else' in a
> try/except/else block.
>
> ~Ethan~
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list