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

Steven D'Aprano steve at pearwood.info
Fri Nov 11 00:43:12 CET 2011

Guido van Rossum wrote:
> On Thu, Nov 10, 2011 at 5:35 AM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
>> "except: raise" makes it explicit that an exception is to be propogated.
>>  Far from being pointless it makes the code much more readable.  "Explicit
>> is better than implicit."
> +1. Nobody's going to understand try...else... on first reading.

Nobody's going to understand try...finally on first reading either, or 
for...else. And I can tell you, the first time I saw Python code, I had 
no idea how to translate "for x in something" into idioms I understood. 
The only for loops I had ever seen before then had been "for i = 1 to 
100" Pascal/C style loops, and I was completely mystified.

It seems somewhat bizarre to me that in another thread we are talking 
about about adding "cofunctions" to a language that already has threads, 
generators, coroutines and metaclasses, and then on the other hand we're 
worried that users won't be able to generalise try...else...finally from 

However, Terry's explanation of Dennis' observation that any 
hypothetical try...else...finally block can be re-written as 
try...finally satisfies me. That's a good enough reason to keep the 
status quo.

Downgrading my vote from +1 to +0.


More information about the Python-ideas mailing list