Last Updated: February 25, 2016
·
376
· 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