Slight irritation with try/finally indentation
Ken Seehof
kseehof at neuralintegrator.com
Fri May 3 23:48:32 EDT 2002
David Eppstein wrote:
> 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()
>
Hmm. This thread reminds me of the brilliant solution to the
very serious :-) lack of begin and end block markers for python:
if x:
#begin
for j in range(4): #{
f(j);
#}
#endif
I wonder how many python programmers would have switched to a
different language if Fredrik Lundh and Michael McLay hadn't
made these undocumented keywords known to the public.
http://www.python.org/doc/Humor.html#parsing
- Ken
More information about the Python-list
mailing list