Slight irritation with try/finally indentation

David Eppstein eppstein at ics.uci.edu
Fri May 3 14:41:27 EDT 2002


In article <3cd2c922.692157118 at news>,
 ullrich at math.okstate.edu (David C. Ullrich) wrote:

> >    setup()
> >    try:
> >        process()
> >    finally:
> >        cleanup()
> >    [...]
> >
> >What I find irritating is that `cleanup()' is not aligned anymore with
> >`setup()', as it was originally, so we loose on the legibility of the
> >parenthetical idiom we wanted to stress.  
> 
> Exactly the same thing bothered me years ago with try-finally in
> another language (where the indentation was optional). I never
> got around to complaining about it, though...

You could always do

if 1: # indent to match try-finally
   setup()
try:
   process()
finally:
   cleanup()

-- 
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/



More information about the Python-list mailing list