Does Python do try: except: finally: ?

Ulrich Petri ulope at gmx.de
Wed Mar 19 19:01:47 EST 2003


"Skip Montanaro" <skip at pobox.com> schrieb im Newsbeitrag
news:mailman.1048112434.6123.python-list at python.org...
>
> Maybe, but that's not what try/finally does.  Try/finally says, "Execute
the
> code in the try block, and irregardless of any exceptions which might get
> raised, execute the code in the finally block when finished."
> Try/except/else says, "Execute the code in the try block.  If an exception
> is raised, execute the code in the except block, otherwise execute the
code
> in the else block."
>

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?

Ciao Ulrich






More information about the Python-list mailing list