Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 2088

Python Errors and Built-in Exceptions

$
0
0
When writing a program, we, more often than not, will encounter errors. Error caused by not following the proper structure (syntax) of the language is called syntax error or parsing error. >>>> if a < 3 File "", line 1 if a < 3 ^ SyntaxError: invalid syntax We can notice here that a colon is missing in the if statement. Errors can also occur at runtime and these are called exceptions. They occur, for example, when a file we try to open does not exist (FileNotFoundError), dividing a number by zero (ZeroDivisionError), module we try to import is not found (ImportError) etc. Whenever these type of runtime error occur, Python creates an exception object. If not handled properly, it prints a traceback to that error along with some details about why that error occurred.

Viewing all articles
Browse latest Browse all 2088

Trending Articles