try: finally: question

Antoon Pardon apardon at
Wed Jul 7 17:43:33 CEST 2004

Op 2004-07-06, Peter Hansen schreef <peter at>:
> djw wrote:
>> OK, yeah, I think you are correct. What wasn't apparent to me is that a
>> finally: doesn't stop the exception from continuing to propagate. I just
>> wish you could intermix except: and finally: within the same try: block.
> You used to be able to do that, according to a recent thread on the
> subject.  It was removed because it was ambiguous what would happen.
> For example, if an exception were raised in a finally clause which
> came just before the except clause, would the except clause catch it?
> Since the finally is technically outside of the try block, some
> people thought it shouldn't be caught by the following except.
> Others did.  Guido nuked it.
> Anyway, it would be purely syntactic sugar for what we have now,
> saving you a few keystrokes and one extra level of indentation.
> No big deal.

I don't agree. It is not unusual to nest try blocks. If you then
need to two instead of one because you can't combine a finally
with an except clause, you almost double the level of indentations.

IMO it is almost as bad as would not having an elif and needing
an extra indentation level for each else .. if

Antoon Pardon

More information about the Python-list mailing list