More Fun With Tracebacks
Okay if you - unlike me - did actually read the documentation of the Python traceback module you probably know that what I wrote here can be archived much easier if you just do this:
try:
1 / 0
except:
import traceback
traceback.print_exc()
And if you want to do something with your traceback like send it per mail you can do like so:
try:
1 / 0
except:
import traceback
import StringIO
fp = StringIO()
traceback.print_exc(file=fp)
print fp.getvalue()