Hierarchy of Exceptions in Python

The Python programming language provides us with an extensive and myriad of exception classifications. The idea behind this classification is to make it easy for us to figure out the nature of the triggered exception so that we can debug it easily.  Let’s say, for instance, any operating system problem would be classified under the … Read more

Python Raising Error With a Custom Message

In this article, we’ll see how to raise an error with a custom message in Python. We’ll learn how to use the ‘raise’ statement and we’ll practice this all with the help of examples. What is the ‘raise’ statement? The ‘raise’ statement allows you to throw/raise any error manually.  For example: Running that results in … Read more

KeyboardInterrrupt: Everything You Need to Know!

In this article, let us learn what KeyboardInterrupt is, and how to effectively handle it in our Python programs. What is KeyboardInterrupt? The KeyboardInterrupt is an exception in Python that is raised when the user presses a pre-defined key-combination while the program is executing. In most operating systems, ctrl + c is used as the … Read more

“raise vs raise e” Explained!

In this article, we will be looking at the ‘raise’ vs ‘raise e’ statements. We will learn what they mean, their differences, and when they are used.  The ‘raise’ statement is used to manually raise an exception in Python. For example, you can manually raise a ValueError exception like this When to use raise by … Read more

“raise ValueError” What does it mean?

In this article, we will learn about the statement ‘raise ValueError’. We will try to understand what it means and when to use it with the help of examples. Without further ado, let’s begin! What is ValueError? To define ValueError in simple terms, it is an exception that is raised when an incorrect value is … Read more

Python Re-Raise the Same Exception

In this article, we will learn how to reraise an exception after you have caught it. We will be explaining the 2 methods to do it with examples. Without further ado, let’s begin! Exceptions can be re-raised for various reasons such as; Here are 2 ways to do that: Method#1: raise inside the except block … Read more