catching exceptions from an except: block

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Mar 9 04:37:08 EST 2007


En Fri, 09 Mar 2007 05:52:35 -0300, Duncan Booth  
<duncan.booth at invalid.invalid> escribió:

> "Gabriel Genellina" <gagsl-py2 at yahoo.com.ar> wrote:
>
>> Not the *previous* exception, but the *current* one. You must be
>> inside an  "except" clause to use a bare raise.
>>
> No, you don't have to be inside an except clause to use a bare raise.
> A bare 'raise' will re-raise the last exception that was active in the
> current scope. That applies even outside the except clauses just so long
> as there has been an exception within the same function:

Oh! Thanks, I didn't know that.
I tested it in the interpreter, outside any function, and the exception  
info was lost immediately, so I wrongly concluded that it lived shortly.

-- 
Gabriel Genellina




More information about the Python-list mailing list