Does Python do try: except: finally: ?
Jeremy Fincher
tweedgeezer at hotmail.com
Wed Mar 19 23:13:56 EST 2003
"Ulrich Petri" <ulope at gmx.de> wrote in message news:<b5b0de$253ft3$1 at ID-67890.news.dfncis.de>...
> 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
raised.
Jeremy
More information about the Python-list
mailing list