๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ builtins โ€บ exceptions.html
Built-in Exceptions โ€” Python 3.14.7 documentation
Raised when the interpreter finds an internal error, but the situation does not look so serious to cause it to abandon all hope. The associated value is a string indicating what went wrong (in low-level terms). In CPython, this could be raised by incorrectly using Pythonโ€™s C API, such as returning a NULL value without an exception set.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_ref_exceptions.asp
Python Built-in Exceptions
The table below shows built-in exceptions that are usually raised in Python.
Discussions

As a beginner how do I understand event/error handling in python?
Some lines of code - mostly function and method calls - are "risky", in the sense that under certain circumstances they aren't guaranteed to succeed. The most risky functions are those that rely on another system succeeding at a task. For instance, if you ask a remote server for a response, you're relying on the remote server to successfully respond. What if it doesn't? What if I've reached over and turned the power off just as you've sent the request? What if the internet stops working at that time? A function relates input to output - the input are the function's parameters, and the output is the return value. But that makes the assumption that a function always yields the return value demanded by its arguments. How does a function indicate when it won't be possible to return that value? That's what exceptions are for - they're a way for the function to terminate in an "exceptional" way, that is, a way that is an exception to the normal operation of the function. Since the exception isn't a return value of the function, but a different and special way for the function to terminate, we use a different term to describe yielding an exception - we say that a function throws an exception. This should bring to mind the idea of "throwing your back out" or "my car threw a piston rod", in the sense of how it indicates something has gone wrong. In other languages, functions that can throw exceptions have to declare that they do, which puts the risks of calling the function up-front but it also requires that when you call those functions, you make some decisions about what to do with exceptions. This is a little bit of an unreasonable expectation on new programmers so Python doesn't require either of these things, and so you should assume that a function might throw an exception if it would be reasonable for it to do so under certain circumstances. Adding two numbers isn't going to throw an exception. Making a remote procedure call on another system is going to throw different kinds of exceptions based on the myriad ways that can go wrong (the system doesn't exist, the system refuses to comply, the system doesn't know how, etc.) When you call a function and it throws an exception, if you don't immediately handle the exception, your function will terminate as well. It'll throw the exception "up" the calling chain, up to the very top level of your program where, if the exception isn't handled, it'll crash your program. This is an important safety tool because it prevents your program from continuing in an undeterminable state. If you want to try to handle the exception - it's predictable and there's some reasonable action your code can take in response, like try again in a couple of seconds or something - then you can use a "try/except" block to enclose the logic that may throw an exception, and handle it if it does. You can choose which exceptions you want to handle via declaration and you can handle different exceptions differently. Or you can handle some and not others. More on reddit.com
๐ŸŒ r/learnpython
8
6
April 23, 2025
Exceptions vs Errors in Python - Stack Overflow
I come from Java where Exceptions and Errors are quite different things and they both derive from something called Throwable. In Java normally you should never try to catch an Error. In Python thou... More on stackoverflow.com
๐ŸŒ stackoverflow.com
29 common beginner Python errors in one flowchart
About the equality check returning True instead of False in if-clauses: I think python protects against using = instead of == and raises a SyntaxError. More on reddit.com
๐ŸŒ r/Python
43
327
August 6, 2013
What mistakes do bad python developers make?
Really, this list is endless. The number of ways a new programmer can screw up is limited only by your imagination. Some things off the top of my head though: A misunderstanding of how = and references work. They think it makes copies, and reassigning references in functions will effect the passed argument. Uses mutable default arguments without understanding why that's almost always a bad thing. Doesn't close resources when they're done with them/doesn't use with to manage resources when with is appropriate. Uses list comprehensions to carry out side effects instead of to produce a list. Doesn't follow PEP8 or any style guidelines consistently. Uses except: without understanding why that's so dangerous. And, catches exceptions but doesn't actually handle the error properly. Uses for i in range(len(coll)): instead of for elem in coll: when the latter is appropriate. Those are just the ones I could think of in a couple minutes. There's likely many more. More on reddit.com
๐ŸŒ r/learnpython
116
156
October 1, 2023
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ errors.html
8. Errors and Exceptions โ€” Python 3.14.7 documentation
Even if a statement or expression is syntactically correct, it may cause an error when an attempt is made to execute it. Errors detected during execution are called exceptions and are not unconditionally fatal: you will soon learn how to handle them in Python programs.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-exception-handling
Python Exception Handling - GeeksforGeeks
The try block contains code that may fail and except block catches the error, printing a safe message instead of stopping the program. Python provides four main keywords for handling exceptions: try, except, else and finally each ...
Published: May 29, 2026
๐ŸŒ
Honeybadger
honeybadger.io โ€บ blog โ€บ errors-in-python
Errors in Python: Types, Causes, and Examples - Honeybadger Developer Blog
April 27, 2026 - Errors in Python are issues in a program that cause incorrect results or prevent proper execution. Some Python errors are loud and obvious, and your code barely gets started before it throws an error that tells you exactly what went wrong. Other errors are more subtle, allowing your Python program to run without complaints while silently producing incorrect results that only become apparent later.
๐ŸŒ
Coursera
coursera.org โ€บ tutorials โ€บ how to catch, raise, and print a python exception
How to Catch, Raise, and Print a Python Exception | Coursera
August 13, 2024 - In the code block above, TypeError is the specified error. It has been set to occur anytime the variable x is not a string. The text inside the parentheses represents your chosen text to print to the user. How would you raise an exception that prints "Sorry, please enter a number greater than or equal to 0" if x is a negative number? ... In an exception block, define the exception and use the print() function. Hereโ€™s an example: ... Why isnโ€™t Python printing my exception?
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ error-handling
Python Error Handling: Syntax, Techniques, and Best Practices
Master Python error handling with try, except, finally, and custom exceptions. Catch, raise, and log errors to build more reliable programs.
Find elsewhere
๐ŸŒ
Tutorial Teacher
tutorialsteacher.com โ€บ python โ€บ error-types-in-python
Error Types in Python
Learn about built-in error types in Python such as IndexError, NameError, KeyError, ImportError, etc.
๐ŸŒ
Sentry
blog.sentry.io โ€บ practical-tips-on-handling-errors-and-exceptions-in-python
Guide to Errors vs Exceptions in Python | Sentry Blog
April 1, 2025 - An IndentationError occurs when Python expects an indented block of code, but the indentation is either missing or incorrect. For example, the code below throws an IndentationError: expected an indented block because of the incorrectly indented ...
๐ŸŒ
Real Python
realpython.com โ€บ python-exceptions
Python Exceptions: An Introduction โ€“ Real Python
March 18, 2026 - Python exceptions provide a mechanism for handling errors that occur during the execution of a program. Unlike syntax errors, which are detected by the parser, Python raises exceptions when an error occurs in syntactically correct code.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ errors-and-exceptions-in-python
Errors and Exceptions in Python - GeeksforGeeks
May 29, 2026 - Example: In this example, the code gives a syntax error because the colon (:) is missing after the if statement. ... Python uses indentation (spaces or tabs at the beginning of a line) to define blocks of code.
Top answer
1 of 7
15
Some lines of code - mostly function and method calls - are "risky", in the sense that under certain circumstances they aren't guaranteed to succeed. The most risky functions are those that rely on another system succeeding at a task. For instance, if you ask a remote server for a response, you're relying on the remote server to successfully respond. What if it doesn't? What if I've reached over and turned the power off just as you've sent the request? What if the internet stops working at that time? A function relates input to output - the input are the function's parameters, and the output is the return value. But that makes the assumption that a function always yields the return value demanded by its arguments. How does a function indicate when it won't be possible to return that value? That's what exceptions are for - they're a way for the function to terminate in an "exceptional" way, that is, a way that is an exception to the normal operation of the function. Since the exception isn't a return value of the function, but a different and special way for the function to terminate, we use a different term to describe yielding an exception - we say that a function throws an exception. This should bring to mind the idea of "throwing your back out" or "my car threw a piston rod", in the sense of how it indicates something has gone wrong. In other languages, functions that can throw exceptions have to declare that they do, which puts the risks of calling the function up-front but it also requires that when you call those functions, you make some decisions about what to do with exceptions. This is a little bit of an unreasonable expectation on new programmers so Python doesn't require either of these things, and so you should assume that a function might throw an exception if it would be reasonable for it to do so under certain circumstances. Adding two numbers isn't going to throw an exception. Making a remote procedure call on another system is going to throw different kinds of exceptions based on the myriad ways that can go wrong (the system doesn't exist, the system refuses to comply, the system doesn't know how, etc.) When you call a function and it throws an exception, if you don't immediately handle the exception, your function will terminate as well. It'll throw the exception "up" the calling chain, up to the very top level of your program where, if the exception isn't handled, it'll crash your program. This is an important safety tool because it prevents your program from continuing in an undeterminable state. If you want to try to handle the exception - it's predictable and there's some reasonable action your code can take in response, like try again in a couple of seconds or something - then you can use a "try/except" block to enclose the logic that may throw an exception, and handle it if it does. You can choose which exceptions you want to handle via declaration and you can handle different exceptions differently. Or you can handle some and not others.
2 of 7
3
Read about exceptions: https://docs.python.org/3/tutorial/errors.html
Top answer
1 of 2
43
  1. Yes. SyntaxError isn't catchable except in cases of dynamically executed code (via eval/exec), because it occurs before the code is actually running.
  2. "Fatal" means "program dies regardless of what the code says"; that doesn't happen with exceptions in Python, they're all catchable. os._exit can forcibly kill the process, but it does so by bypassing the exception mechanism.
  3. There is no difference between exceptions and errors, so the nomenclature doesn't matter.
  4. System-exiting exceptions derive from BaseException, but not Exception. But they can be caught just like any other exception
  5. Warnings behave differently based on the warnings filter, and deriving from Exception means they're not in the "system-exiting" category
  6. AssertionError is just another Exception child class, so it's not "system exiting". It's just tied to the assert statement, which has special semantics.
  7. Things deriving from BaseException but not Exception (e.g. SystemExit, KeyboardInterrupt) are "not reasonable to catch" (or if you do catch them, it should almost always be to log/perform cleanup and rethrow them), everything else (derived from Exception as well) is "conditionally reasonable to catch". There is no other distinction.

To be clear, "system-exiting" is just a way of saying "things which except Exception: won't catch"; if no except blocks are involved, all exceptions (aside from warnings, which as noted, behave differently based on the warnings filter) are "system-exiting".

2 of 2
2

Exceptions are designed for the programmer to know how to handle them such as outOfRange Once an exception arises the programmer has to decide how to handle it and the code can continue to operate relatively smoothly

On the other hand an error indicates a problem that the programmer could not foresee as an import error or a memory error Errors can still be addressed and ensure that the software continues to run but apparently not everything will be able to continue to work smoothly.

๐ŸŒ
APXML
apxml.com โ€บ courses โ€บ python-for-beginners โ€บ chapter-9-handling-errors-exceptions โ€บ python-understanding-errors
Understanding Errors in Python | Syntax vs Exceptions
If you try to run this code, Python will stop and point out the problem before executing any of it: File "your_script_name.py", line 3 if number > 5 ^ SyntaxError: expected ':' The error message usually tells you the file name (your_script_name.py), the line number where the error was detected (line 3), and sometimes uses a caret (^) to indicate the exact position of the problem.
๐ŸŒ
Miguel Grinberg
blog.miguelgrinberg.com โ€บ post โ€บ the-ultimate-guide-to-error-handling-in-python
The Ultimate Guide to Error Handling in Python - miguelgrinberg.com
It is a big improvement that with this pattern the target function is tasked with checking and reporting errors, so we as callers can make the call and trust that the function will let us know if the action failed. On the other side, we need to know what exceptions to write down in the except clause, because any exception classes that we miss are going to bubble up and potentially cause the Python application to crash.
๐ŸŒ
Reddit
reddit.com โ€บ r/python โ€บ 29 common beginner python errors in one flowchart
r/Python on Reddit: 29 common beginner Python errors in one flowchart
August 6, 2013 - Finally some are completely false, you can't have a single equal in a boolean context, assignment is a statement and if a = b is a syntax error. ... One can understand why you'd want to type that, especially given Python's flow.
๐ŸŒ
Last9
last9.io โ€บ blog โ€บ types-of-errors-in-python
Types of Errors in Python: Syntax, Runtime, and Logical Explained | Last9
January 3, 2025 - Python errors fall into three types: syntax, runtime, and logical. What each one means, the exceptions that belong to it, and how to fix them.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ what mistakes do bad python developers make?
r/learnpython on Reddit: What mistakes do bad python developers make?
October 1, 2023 -

Hello

Iโ€™m currently learning python and seeking some guidance as to what to avoid.

What do you think makes someone a bad python programmer? Except having unreadable code, what else instantly signals red flag.

๐ŸŒ
Rollbar
rollbar.com โ€บ home โ€บ what are the different types of python errors? โ€“ and how to handle them
What are the Different Types of Python Errors? โ€“ and How to Handle Them
Learn how to fix common Python errors: SyntaxError, TypeError, NameError, IndexError, and more. Each error type explained with code examples and solutions.
Published: July 14, 2025
๐ŸŒ
Inngest
inngest.com โ€บ blog โ€บ python-errors-as-values
Python errors as values: Comparing useful patterns from Go and Rust - Inngest Blog
November 8, 2023 - Demonstrate how to handle errors as values in Python (a traditionally thrown-error language).