How to Print the Exception Without Exiting Your Python Program?

Problem Formulation Given a basic Python program. How to print an exception if it occurs without exiting the program? For example, consider the following program that raises a ZeroDivisionError: division by zero. The output is: You want the program to keep running and executing the print statement after giving you a note about the exception: … Read more

Python Pass Statement

The pass statement does nothing when executed. You can use it as a placeholder for future code so that you can focus on the high-level structure first and implement the details later. For example, functions, loops, class definitions, or if statements require at least one statement in their indentation block. Think of the pass statement … Read more

How to Ignore Exceptions the Pythonic Way?

If you are an application developer, you might have to implement an error-free code that is well tested. In my instances, we would like to ignore I/O or Numerical exceptions. In this blog post, you will learn how we can safely ignore exceptions in Python. Imagine you are working on an application  where you have … Read more