Usually it is advised to initialize cgitb at the beginning of a script with the function cgitb.enable()
.
But how can I do to use cgitb to format a special exception I catched in a try/except block, without registering cgitb as a global exception handler?
I suppose it would look like this:
import cgitb
try:
1/0
except Exception as exc:
print(cgitb.something(exc))