Slight irritation with try/finally indentation

Stephen J. Turnbull stephen at xemacs.org
Sat May 4 13:31:05 EDT 2002


>>>>> "François" == François Pinard <pinard at iro.umontreal.ca> writes:

[Alex Martelli]
> François Pinard wrote:

> > [Stephen J. Turnbull]
>         ...
> >>     try:
> >>         setup()
> >>         process()
> >>     except SetupError:
> >>         pass
> >>     else:
> >>         cleanup()
> > 
> > Clever, and nice.  Thanks for this idea, I'll ponder it.

> But this only calls cleanup if process does NOT raise.  NOT the same
> semantics as a try/finally *at all*!

> What am I missing...?

    François> I misread it, sorry.

But AFAICT it does what you want.  process() never raises SetupError.
Only setup() does that.

This may require some uglification in setup() or process() to
guarantee that their errors are disjoint.

-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
 My nostalgia for Icon makes me forget about any of the bad things.  I don't
have much nostalgia for Perl, so its faults I remember.  Scott Gilbert c.l.py



More information about the Python-list mailing list