It would not be nice if the traceback module API started providing text with embedded escape sequences without a way to turn then off in the API.
I think fobj.isatty() would give the traceback module a good idea whether it's writing to a display device or not. There are a number of other complications though (APIs, platform differences, TERM environment variables or lack thereof, forcible overriding through an API, what other systems (IDLE, PyCharm, etc) do, ...). If it seems the right place to make a change is in the traceback module, my recommendation would be to fork the existing module and publish your prototype on PyPI. Here's a PyPI module (last updated several years ago) that purports to color traceback output: https://pypi.org/project/colored-traceback/ (This really belongs on python-ideas, right?) Skip