ask help about raise, thank u

Emile van Sebille emile at fenx.com
Tue Feb 26 08:48:27 EST 2002


"John Machin" 
>       # re-raise the exception, with traceback giving the *original*
>       # source of the problem (somewhere inside the 'try' suite),
>       # not the 'raise' statement
>       raise exc, data, tb
> 

Isn't this what raise by itself does?

>>> def test(d=None):
...     try:
...             1/d
...     except TypeError:
...             return 0
...     except:
...             raise
...
>>> test()
0
>>> test(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 3, in test
ZeroDivisionError: integer division or modulo by zero
>>>

-- 

Emile van Sebille
emile at fenx.com

---------




More information about the Python-list mailing list