What about try:except:finally

Martin von Loewis loewis at informatik.hu-berlin.de
Sun Jul 9 06:12:53 EDT 2000


Matthew Schinckel <baron at null.net> writes:

> Yes, but if you want a statement executed regardless of whether there was
> an exception or not, you need to use a finally clause.

That also shows that having try:except:finally is perhaps not a good
idea. Given

try:
  A
except:
  B
finally:
  C

is that the same as

try:
  try:
    A
  finally:
    C
except:
  B

or as

try:
  try:
    A
  except:
    B
finally:
  C

or is it something else? If so, what would it be? And why not one of
the others?

Regards,
Martin




More information about the Python-list mailing list