Does Python do try: except: finally: ?

Jerry Seutter jerry.seutter at pason.com
Wed Mar 19 15:51:47 EST 2003


Does Python do a block like:

try:
    do_something()
except:
    do_something_else()
finally:
    do_cleanup()

Python gives me an error when I try to do this and the
online documentation only gives examples with try-except
and try-finally blocks. To get around this I do:

try:
    try:
        do_something()
    except:
        do_something_else()
finally:
    do_cleanup()

Is this the way it has to be done?

Thanks for your help,
Jerry Seutter






More information about the Python-list mailing list