Simple (traceback) Errors In Standard Python 3.x

Asked By 0 points N/A Posted on -
qa-featured

I am a beginner in python. When I type in the standard python interpreter and if geta any errors, I get only a few lines of the error. I need the complete message sometimes so I can get a clearer picture. What should I do?

SHARE
Answered By 0 points N/A #324219

Simple (traceback) Errors In Standard Python 3.x

qa-featured

We all know the most common types of errors that we come across are syntax errors, logical errors, and exceptions. Python interpreter usually raises an exception whenever it encounters an error. The most usual kind is a traceback error.

So if you want to get more information about the error you encountered try the following.

import traceback

import sys

try:

do_stuff()

except Exception:

print(traceback.format_exec())

# or you can type the following, both will give you a clearer picture.

print(sys.exc_info()[0])

Related Questions