refactoring a group of import statements
Aahz
aahz at pythoncraft.com
Tue Jun 29 15:45:28 EDT 2010
In article <mailman.2202.1277677180.32709.python-list at python.org>,
Thomas Jollans <thomas at jollans.com> wrote:
>
>(3) Why not
>
>try:
> import x
> import y
> import z
>except ImportError as exc:
> display_error_properly(exc)
> raise exc
Why not? Because that destroys the original traceback. Inside an
except clause, you should almost always use a bare raise. (I'm not
absolutely certain that the new "as" subclause doesn't fix the problem,
but why not stick with an idiom guaranteed to work in all versions of
Python.)
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"If you don't know what your program is supposed to do, you'd better not
start writing it." --Dijkstra
More information about the Python-list
mailing list