Artificial truth

The more you see, the less you believe.

[archives] [latest] | [homepage] | [atom/rss/twitter]

Fun with python
Thu 15 November 2012 — download

What does this snippet print ?

def my_function():
        return 1/0
    except Exception:
        return "Exception"
        return "Finally"

print my_function()


$ python

This black magic is explainedin the documentation:

When return passes control out of a try statement with a finally clause, that finally clause is executed before really leaving the function.

You can know ask this uncomfortable questions to your favorite python developer :)