what manual? On Wed, Jun 23, 2010 at 10:59 PM, bob gailer <bgai...@gmail.com> wrote:
> On 6/23/2010 7:36 PM, Christopher King wrote: > > In a try except clause, you can end with finally block. I know it runs > after the try and except blocks regardless of the outcome, but why use it. > Couldn't you just put the code after the try and except block without using > a finally block. Does the finally command do something I don't know about. > Does it make your program more understandable in some way? > > > Did you read the manual? > > "If finally <#12967e4e8be99cad_finally> is present, it specifies a > ‘cleanup’ handler. The try <#12967e4e8be99cad_try> clause is executed, > including any except <#12967e4e8be99cad_except> and > else<#12967e4e8be99cad_else>clauses. If an exception occurs in any of the > clauses and is not handled, > the exception is temporarily saved. The > finally<#12967e4e8be99cad_finally>clause is executed. If there is a saved > exception, it is re-raised at the > end of the finally <#12967e4e8be99cad_finally> clause. If the > finally<#12967e4e8be99cad_finally>clause raises another exception or executes > a > return <http://simple_stmts.html#return> or > break<http://simple_stmts.html#break>statement, the saved exception is lost. > The exception information is not > available to the program during execution of the > finally<#12967e4e8be99cad_finally>clause. > > "When a return <http://simple_stmts.html#return>, > break<http://simple_stmts.html#break>or > continue <http://simple_stmts.html#continue> statement is executed in the > try <#12967e4e8be99cad_try> suite of a try <#12967e4e8be99cad_try>... > finally <#12967e4e8be99cad_finally> statement, the > finally<#12967e4e8be99cad_finally>clause is also executed ‘on the way out.’ A > continue <http://simple_stmts.html#continue> statement is illegal in the > finally <#12967e4e8be99cad_finally> clause. (The reason is a problem with > the current implementation — this restriction may be lifted in the future)." > > -- > Bob Gailer > 919-636-4239 > Chapel Hill NC > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor