Re: [python] using try: finally: except

From: Antoon Pardon (apardon_at_forel.vub.ac.be)
Date: 06/28/04


Date: 28 Jun 2004 12:59:30 GMT

Op 2004-06-25, Tim Peters schreef <tim.peters@gmail.com>:
> [Tim Peters]
>>> It's more that Guido deliberately separated them. Before Python
>>> 0.9.6, you could attach both 'except' and 'finally' clauses to the
>>> same 'try' structure (see Misc/HISTORY in a Python source
>>> distribution). I don't remember the semantics, and that was indeed
>>> the problem: nobody could remember, and half the time guessed wrong.
>
> [Peter Hansen]
>> I'm curious: was it that the order of execution was fixed, regardless
>> of the order of the 'finally' and 'except' in the source, or was
>> it still confusing even though the order of execution changed
>> logically with the order of the statements in the source?
>
> If present, a 'finally' clause had to be the last clause in a
> try/except/finally structure. That was enforced by the syntax. The
> most common confusion was over whether the code in the 'finally'
> clause would execute if an exception was raised during execution of an
> 'except' clause. That code isn't in the 'try' block, so why should
> 'finally' apply to it?

Well personnaly I wouldn't find it that hard to aswer this.

The finally clause is to finalise code in the try block.
That an exception occured in an except clause doesn't change
that.

-- 
Antoon Pardon


Relevant Pages

  • Re: Evaluating Exceptions, Try Except and Try Finally
    ... error occurs during execution. ... statementList2 (the finally clause) is executed. ... exception is raised during execution of statementList1, ... THE IF THEN ELSE STATEMENT DOCUMENTATION IS JUST AS FUCKED:)' ...
    (alt.comp.lang.borland-delphi)
  • Re: Undead Persistence, wording of optional press
    ... if that clause doesn't turn ... Undead Persistence into superior Conquer the Beast, ... they would have had to have seen it on another card. ... As I said, read by itself, the card is just not that confusing. ...
    (rec.games.trading-cards.jyhad)
  • Re: Sorting Problem
    ... "nomi" wrote in message ... Only by running SELECT clause and specify ORDER BY clause you can ... >>> I presume that it has something to do with collations, ... >>> Here is the output of the query after different execution of the sp. ...
    (microsoft.public.sqlserver.programming)
  • Re: how eval works?
    ... of execution. ... Also it confusing when it compiles the code & when not ... therefore, during parsing, load every MAT-file that you try to load in your ... it's just as easy to prompt the user for a filename as it is to prompt for a ...
    (comp.soft-sys.matlab)
  • Re: SET NOLOGGING in JDBC url?
    ... It's right it does not have a where clause, the query *should* run ... execution at a time ... isolation level could be the key in this case. ...
    (comp.databases.ingres)