Right now, I catch the exception in the except Exception: clause, and do print(exception). The result provides no information since it always prints
except Exception:
print(exception)
Although if you want a code that is compatible with both python2 and python3 you can use this:
import logging try: 1/0 except Exception as e: if hasattr(e, 'message'): logging.warning('python2') logging.error(e.message) else: logging.warning('python3') logging.error(e)