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

Terry Reedy tjreedy at udel.edu
Thu Nov 10 20:55:34 CET 2011


On 11/10/2011 8:28 AM, Steven D'Aprano wrote:

> try:
> ...
> else:
> # Run the else block unless we exit the try block with an exception.
> ...

As Dennis Kaarsemaker already pointed out in his response to the OP, the 
'else:' is not needed and this is the same (unless we are missing 
something) as

try:
   ...
   ...

In other words, *every* statement in a try block after the first is 
preceded by an implicit 'run this unless we already exited with an 
exception'.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list