Dup Ver Goto 📝

TracebackModule

PT2/aw/lang/python does not exist
To
12 lines, 36 words, 411 chars Page 'TracebackModule' does not exist.

See docs here. Note that sys.exception(), within an except, returns the current exception.

import traceback
from datetime import datetime
try:
  open("does_not_exist")
except Exception as e:
  traceback.print_exc()
  with open("exc.txt","at") as f:
    print(f"==[ {datetime.now().strftime('%c')} ]==",file=f)
    traceback.print_exc(file=f)