This is very easily a duplicate question--because it is. However, there are very many inadequate answers to this (e.g. try curses! -- pointing to a 26 page docu
The problem I faced was how to output error messages in IDLE properly, since sys.exc_info() is printed like normal output while traceback.print_exc() is a bit of too long and detailed. So, I just want to print the Exception in red color like "traceback".
Thanks the top anwser for letting me learn about specifying the type of my messages with write(). Accidentally, I've found another method that meets my demmand by simplely adding file=sys.stderr while print(). Then I'll get a striking but brief error messages. An example in python 3.6:
import sys
try:
1/0
except Exception as e:
print(repr(e), file=sys.stderr)