Slight irritation with try/finally indentation

François Pinard pinard at iro.umontreal.ca
Sat May 4 12:56:04 EDT 2002


[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...?

Oops, indeed!  I guess I unconsciously read 'finally:' for `else:' without
realising that 'try:' flavours do not mix that way.  Or, maybe, my brain
started evaporating under the combined effect of spring with the nice
sun, outside!  Or simply, happiness blinded me! :-) I misread it, sorry.
-------------- next part --------------

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard


More information about the Python-list mailing list