I am learning python. What are some best practices to handle in python errors. Want some useful python error handling best practices.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
kushwanth
Python is an interpreted language and simple so handling errors can be
minimized by
1.Using TRY and EXCEPT block: it is used to catch and handle exceptions.it executes the TRY statement code as a normal part of the program whereas the EXCEPT statement is the response to any exceptions in the preceding TRY clause.
2.Make sure there are no syntax errors or parsing error
3.Make sure there are no Logical errors i.e.trying to open a file that does not exist,trying to import a module that does not exist
4.built-in exceptions:These can be viewed using LOCAL() function
5.Make sure there are no USER-DEFINED EXCEPTION