catching exceptions from an except: block
Steven D'Aprano
steve at REMOVEME.cybersource.com.au
Thu Mar 8 19:11:54 EST 2007
On Thu, 08 Mar 2007 06:31:20 -0300, Gabriel Genellina wrote:
> En Thu, 08 Mar 2007 06:17:37 -0300, Gerard Flanagan
> <grflanagan at yahoo.co.uk> escribió:
>
>> @onfail(False)
>> def a(x):
>> if x == 1:
>> return 'function a succeeded'
>> else:
>> raise
>
> I know it's irrelevant, as you use a bare except, but such raise looks a
> bit ugly...
I thought "raise" on its own was supposed to re-raise the previous
exception, but I've just tried it in the interactive interpreter and it
doesn't work for me.
>>> raise ValueError # prime a "previous exception"
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError
>>> raise # re-raise the previous exception?
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: exceptions must be classes, instances, or strings (deprecated), not NoneType
Have I misunderstood?
--
Steven D'Aprano
More information about the Python-list
mailing list