
On Fri, Jul 17, 2009 at 4:41 PM, Michael<fuzzyman@gmail.com> wrote:
Here are two examples of why allowing return inside a finally block is a bad idea:
def f(): try: return 3 finally: return 4
def f(): try: raise Exception() finally: return 4
Well, too bad. As others have (gently) tried to point out, there will always remain a gray area for what should be accepted and what shouldn't. Feel free to put in your company's style guide that this is a bad idea. In most cases it probably is. But I don't think the parser should police this particular issue. (And were you surprised anyway? Since you agree that an exception raised in a finally block has well-defined semantics, why wouldn't a return statement?) -- --Guido van Rossum (home page: http://www.python.org/~guido/)