diff -r 048381e58162 Doc/reference/compound_stmts.rst --- a/Doc/reference/compound_stmts.rst Mon May 05 07:34:56 2014 -0700 +++ b/Doc/reference/compound_stmts.rst Mon May 05 10:16:20 2014 -0500 @@ -337,6 +337,21 @@ reason is a problem with the current implementation --- this restriction may be lifted in the future). +The return value of a function is determined by the last :keyword:`return` +statement executed. Since the :keyword:`finally` clause always executes (even +after a successful :keyword:`return` statement in the :keyword:`try` suite), +a :keyword:`return` statement executed in the :keyword:`finally` clause will +always "win":: + + >>> def foo(): + ... try: + ... return 'try' + ... finally: + ... return 'finally' + ... + >>> foo() + 'finally' + Additional information on exceptions can be found in section :ref:`exceptions`, and information on using the :keyword:`raise` statement to generate exceptions may be found in section :ref:`raise`.