Question on try/except
Kirk McDonald
kirklin.mcdonald at gmail.com
Mon Aug 7 23:49:04 EDT 2006
Dan wrote:
> While perusing sre.py in the standard library, I came upon this snippet
> of code in the _compile() function definition:
>
> try:
> p = sre_compile.compile(pattern, flags)
> except error, v:
> raise error, v # invalid expression
>
> Is there some particular use in catching an exception and immediately
> re-raising it? Why catch it at all?
>
> /Dan
>
All I can think of is that it changes the traceback to point to the
re-raise and not the original raise.
-Kirk McDonald
More information about the Python-list
mailing list