Is there an easy way to get the message of the exception to be colored on the command line? For example
def g(): f() def f(): 1/0 g()
Found another way to do this using the IPython module which is likely a dependency that everyone already has installed:
from IPython.core.ultratb import ColorTB c = ColorTB() exc = sys.exc_info() print(''.join(c.structured_traceback(*exc)))