koool koool - 1 year ago 298
Python Question

e.printStackTrace equivalent in python

I know that print e {where e is Exception} prints the occurred exception
but, I was trying to find the python equivalent of

that exactly traces the exception what line it occurred and prints the entire trace of it.

Could anyone please tell me the equivalent of
in python?

Answer Source
import traceback

When doing this inside an except ...: block it will automatically use the current exception. See http://docs.python.org/library/traceback.html for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download