
July 17, 2009
10:17 p.m.
Greg Ewing writes:
Michael wrote:
Here are two examples of why allowing return inside a finally block is a bad idea:
Don't do those things, then!
Nobody is *forcing* you to write returns inside finally blocks.
+1 Why not just emphasize in the documentation that return (etc) in a finally: suite *will* get executed *after* return or an exception is raised in the try: suite? "These stunts were performed by professionals. Don't try this at home, kids." More specifically, maybe there should be an explicit warning that in a finally: suite if exit_condition: return do_work() # end of suite has (perhaps surprisingly, YMMV) different semantics from if not exit_condition: do_work() # end of suite WDOT?