Last Updated: August 01, 2023
·
423
· socek

Do something after return

There is a trick in #Python which allows you to do something after return. This is dirty and should be used only to debug something! We just use try/finally with return statement.

def somefun():
    data = {}
    try:
        return data
    finally:
        print data