Does Python do try: except: finally: ?

Jeremy Fincher tweedgeezer at
Thu Mar 20 05:13:56 CET 2003

"Ulrich Petri" <ulope at> wrote in message news:<b5b0de$253ft3$1 at>...
> I allways asked myself of what practical use finally (except the syntactical
> "clearness of code") is?
> I can simply write like:
> try:
>     do_this()
> except:
>     print "error"
> #now here is what will be executed next, so what for i do need finally?

Blanketly catching exceptions is a bad idea -- you shouldn't catch
certain exceptions (KeyboardInterrupt, SystemExit, etc.)  "finally"
exists so you can do cleanup without catching the exception that was


More information about the Python-list mailing list