René's URL Explorer Experiment


Title: Python Exceptions: An Introduction – Real Python

Open Graph Title: Python Exceptions: An Introduction – Real Python

Description: In this beginner tutorial, you'll learn what exceptions are good for in Python. You'll see how to raise exceptions and how to handle them with try ... except blocks.

Open Graph Description: In this beginner tutorial, you'll learn what exceptions are good for in Python. You'll see how to raise exceptions and how to handle them with try ... except blocks.

Mail addresses
?subject=Python article for you&body=Python Exceptions: An Introduction on Real Python https://realpython.com/python-exceptions/

Opengraph URL: https://realpython.com/python-exceptions/

X: @realpython

direct link

Domain: realpython.com


Hey, it has json ld scripts:
{
  "@context": "http://schema.org",
  "@type": "Article",
  "headline": "Python Exceptions: An Introduction",
  "image": {
    "@type": "ImageObject",
    "url": "https://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.jpg",
    "width": 1920,
    "height": 1080
  },
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "https://realpython.com/python-exceptions/",
    "lastReviewed": "2024-12-01",
    "author": {
      "@type": "Person",
      "name": "Said van de Klundert",
      "image": "https://realpython.com/cdn-cgi/image/width=335,height=335,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/AAEAAQAAAAAAAAQiAAAAJGJmOGNlMzMzLTg1MmEtNGQwYy1hZDkyLTEwYzI0MjRjNTZkOA_2.8aa7cc5bf1f9.jpg",
      "url": "https://realpython.com/team/svdklundert/",
      "affiliation": {
        "@type": "Organization",
        "@id": "https://realpython.com/#organization",
        "name": "Real Python",
        "url": "https://realpython.com",
        "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
      }
    },
    "reviewedBy": [
      {
        "@type": "Person",
        "name": "Adriana Cutenco",
        "image": "https://realpython.com/cdn-cgi/image/width=900,height=900,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/acutenco.676e4197c133.jpg",
        "url": "https://realpython.com/team/acutenco/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Brenda Weleschuk",
        "image": "https://realpython.com/cdn-cgi/image/width=320,height=320,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/IMG_3324_1.50b309355fc1.jpg",
        "url": "https://realpython.com/team/bweleschuk/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Bartosz Zaczy\u0144ski",
        "image": "https://realpython.com/cdn-cgi/image/width=1694,height=1694,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/coders_lab_2109368.259b1599fbee.jpg",
        "url": "https://realpython.com/team/bzaczynski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Geir Arne Hjelle",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/gahjelle.470149ee709e.jpg",
        "url": "https://realpython.com/team/gahjelle/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Joanna Jablonski",
        "image": "https://realpython.com/cdn-cgi/image/width=800,height=800,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/jjablonksi-avatar.e37c4f83308e.jpg",
        "url": "https://realpython.com/team/jjablonski/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Kate Finegan",
        "image": "https://realpython.com/cdn-cgi/image/width=400,height=400,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/VZxEtUor_400x400.7169c68e3950.jpg",
        "url": "https://realpython.com/team/kfinegan/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      },
      {
        "@type": "Person",
        "name": "Martin Breuss",
        "image": "https://realpython.com/cdn-cgi/image/width=456,height=456,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/martin_breuss_python_square.efb2b07faf9f.jpg",
        "url": "https://realpython.com/team/mbreuss/",
        "affiliation": {
          "@type": "Organization",
          "@id": "https://realpython.com/#organization",
          "name": "Real Python",
          "url": "https://realpython.com",
          "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
        }
      }
    ]
  },
  "datePublished": "2024-12-01T14:00:00+00:00",
  "dateModified": "2024-12-01T14:09:26.410718+00:00",
  "publisher": {
    "@type": "Organization",
    "@id": "https://realpython.com/#organization",
    "name": "Real Python",
    "url": "https://realpython.com",
    "logo": {
      "@type": "ImageObject",
      "url": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png",
      "width": 512,
      "height": 512
    },
    "description": "Real Python is a leading provider of online Python education and one of the largest language-specific online communities for software developers. It publishes high-quality learning resources, such as tutorials, books, and courses to an audience of millions of developers, data scientists, and machine learning engineers each month.",
    "slogan": "Become a Python Expert",
    "email": "info@realpython.com",
    "sameAs": [
      "https://github.com/realpython",
      "https://www.youtube.com/realpython",
      "https://twitter.com/realpython",
      "https://x.com/realpython",
      "https://www.linkedin.com/company/realpython-com/",
      "https://www.facebook.com/learnrealpython",
      "https://www.instagram.com/realpython",
      "https://www.tiktok.com/@realpython.com"
    ]
  },
  "author": {
    "@type": "Person",
    "name": "Said van de Klundert",
    "image": "https://realpython.com/cdn-cgi/image/width=335,height=335,fit=crop,gravity=auto,format=auto/https://files.realpython.com/media/AAEAAQAAAAAAAAQiAAAAJGJmOGNlMzMzLTg1MmEtNGQwYy1hZDkyLTEwYzI0MjRjNTZkOA_2.8aa7cc5bf1f9.jpg",
    "url": "https://realpython.com/team/svdklundert/",
    "affiliation": {
      "@type": "Organization",
      "@id": "https://realpython.com/#organization",
      "name": "Real Python",
      "url": "https://realpython.com",
      "logo": "https://realpython.com/static/real-python-logo-square-512.157ae6bf64ed.png"
    }
  },
  "description": "In this beginner tutorial, you'll learn what exceptions are good for in Python. You'll see how to raise exceptions and how to handle them with try ... except blocks.",
  "hasPart": {
    "@type": "FAQPage",
    "mainEntity": [
      {
        "@type": "Question",
        "name": "What are exceptions in Python?",
        "acceptedAnswer": {
          "@type": "Answer",
          "text": "

Exceptions in Python are errors that occur during the execution of a program, disrupting the normal flow of the program.

" } }, { "@type": "Question", "name": "How are exceptions handled in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You handle exceptions in Python using a tryexcept block. Python executes the code in the try block and if an exception occurs, it switches to executing the code in the except block to handle the exception. However, only the exceptions that are explicitly specified in the except block will be handled. If an exception is not caught, it’ll propagate up the call stack and may result in the termination of your program.

" } }, { "@type": "Question", "name": "How do you catch all exceptions in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

To catch all exceptions in Python, you can use a bare except clause or write except Exception, but it’s recommended to catch specific exceptions to avoid masking unexpected errors.

" } }, { "@type": "Question", "name": "How does try \u2026 except in Python work?", "acceptedAnswer": { "@type": "Answer", "text": "

In a tryexcept block, Python executes the code under try and if an exception occurs, it immediately jumps to the except block to handle it, allowing the program to continue running.

" } }, { "@type": "Question", "name": "What does try \u2026 except pass do in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

Using tryexcept with pass allows the program to ignore the exception and continue execution without taking any specific action in response to the error. However, this practice can hide potential issues, making it harder to debug and maintain the code, so use it with caution. It’s generally better to either handle the exception explicitly or log it for debugging purposes.

" } }, { "@type": "Question", "name": "How do you raise an exception in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You raise an exception in Python using the raise keyword followed by an exception object, which can include a custom message.

" } }, { "@type": "Question", "name": "What is the purpose of using assert in Python?", "acceptedAnswer": { "@type": "Answer", "text": "

You can use the assert keyword to check if a condition is true during development. If the condition is false, it raises an AssertionError, which can help with debugging. Note that assertions can be disabled by running Python with the -O (optimize) flag. Therefore, you shouldn’t rely on assertions for critical checks in production code, as they may be ignored.

" } }, { "@type": "Question", "name": "What is the role of the finally clause in exception handling?", "acceptedAnswer": { "@type": "Answer", "text": "

The finally clause contains code that will always execute after a try block, regardless of whether an exception was raised or not, ensuring necessary cleanup actions occur.

" } } ] } }

authorReal Python
twitter:cardsummary_large_image
twitter:imagehttps://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.jpg
og:imagehttps://files.realpython.com/media/Python_Exceptions_Watermark.47f814fbeced.jpg
twitter:creator@realpython
og:typearticle

Links:

https://realpython.com/
Start Herehttps://realpython.com/start-here/
Learn Python https://realpython.com/python-exceptions/
Python Tutorials →In-depth articles and video courseshttps://realpython.com/search?kind=article&kind=course&order=newest
Learning Paths →Guided study plans for accelerated learninghttps://realpython.com/learning-paths/
Quizzes & Exercises →Check your learning progresshttps://realpython.com/quizzes/
Browse Topics →Focus on a specific area or skill levelhttps://realpython.com/tutorials/all/
Community Chat →Learn with other Pythonistashttps://realpython.com/community/
Office Hours →Live Q&A calls with Python expertshttps://realpython.com/office-hours/
Podcast →Hear what’s new in the world of Pythonhttps://realpython.com/podcasts/rpp/
Books →Round out your knowledge and learn offlinehttps://realpython.com/products/books/
Reference →Concise definitions for common Python termshttps://realpython.com/ref/
Code Mentor →BetaPersonalized code assistance & learning toolshttps://realpython.com/mentor/
Unlock All Content →https://realpython.com/account/join/
More https://realpython.com/python-exceptions/
Learner Storieshttps://realpython.com/learner-stories/
Python Newsletterhttps://realpython.com/newsletter/
Python Job Boardhttps://www.pythonjobshq.com
Meet the Teamhttps://realpython.com/team/
Become a Tutorial Writerhttps://realpython.com/write-for-us/
Become a Video Instructorhttps://realpython.com/become-an-instructor/
Searchhttps://realpython.com/search
https://realpython.com/search
Joinhttps://realpython.com/account/join/
Sign‑Inhttps://realpython.com/account/login/?next=%2Fpython-exceptions%2F
Browse Topicshttps://realpython.com/tutorials/all/
Guided Learning Pathshttps://realpython.com/learning-paths/
Basicshttps://realpython.com/search?level=basics
Intermediatehttps://realpython.com/search?level=intermediate
Advancedhttps://realpython.com/search?level=advanced
aihttps://realpython.com/tutorials/ai/
algorithmshttps://realpython.com/tutorials/algorithms/
apihttps://realpython.com/tutorials/api/
best-practiceshttps://realpython.com/tutorials/best-practices/
careerhttps://realpython.com/tutorials/career/
communityhttps://realpython.com/tutorials/community/
databaseshttps://realpython.com/tutorials/databases/
data-sciencehttps://realpython.com/tutorials/data-science/
data-structureshttps://realpython.com/tutorials/data-structures/
data-vizhttps://realpython.com/tutorials/data-viz/
devopshttps://realpython.com/tutorials/devops/
djangohttps://realpython.com/tutorials/django/
dockerhttps://realpython.com/tutorials/docker/
editorshttps://realpython.com/tutorials/editors/
flaskhttps://realpython.com/tutorials/flask/
front-endhttps://realpython.com/tutorials/front-end/
gamedevhttps://realpython.com/tutorials/gamedev/
guihttps://realpython.com/tutorials/gui/
machine-learninghttps://realpython.com/tutorials/machine-learning/
newshttps://realpython.com/tutorials/news/
numpyhttps://realpython.com/tutorials/numpy/
projectshttps://realpython.com/tutorials/projects/
pythonhttps://realpython.com/tutorials/python/
stdlibhttps://realpython.com/tutorials/stdlib/
testinghttps://realpython.com/tutorials/testing/
toolshttps://realpython.com/tutorials/tools/
web-devhttps://realpython.com/tutorials/web-dev/
web-scrapinghttps://realpython.com/tutorials/web-scraping/
Table of Contentshttps://realpython.com/python-exceptions/#toc
Understanding Exceptions and Syntax Errorshttps://realpython.com/python-exceptions/#understanding-exceptions-and-syntax-errors
Raising an Exception in Pythonhttps://realpython.com/python-exceptions/#raising-an-exception-in-python
Debugging During Development With asserthttps://realpython.com/python-exceptions/#debugging-during-development-with-assert
Handling Exceptions With the try and except Blockhttps://realpython.com/python-exceptions/#handling-exceptions-with-the-try-and-except-block
Proceeding After a Successful Try With elsehttps://realpython.com/python-exceptions/#proceeding-after-a-successful-try-with-else
Cleaning Up After Execution With finallyhttps://realpython.com/python-exceptions/#cleaning-up-after-execution-with-finally
Creating Custom Exceptions in Pythonhttps://realpython.com/python-exceptions/#creating-custom-exceptions-in-python
Conclusionhttps://realpython.com/python-exceptions/#conclusion
Frequently Asked Questionshttps://realpython.com/python-exceptions/#frequently-asked-questions
https://realpython.com/feedback/survey/article/python-exceptions/liked/?from=article-sidebar
https://realpython.com/feedback/survey/article/python-exceptions/disliked/?from=article-sidebar
Raising and Handling Python Exceptionshttps://realpython.com/courses/raising-handling-exceptions/
Said van de Klunderthttps://realpython.com/python-exceptions/#author
https://realpython.com/python-exceptions/#reader-comments
basicshttps://realpython.com/tutorials/basics/
pythonhttps://realpython.com/tutorials/python/
Understanding Exceptions and Syntax Errorshttps://realpython.com/python-exceptions/#understanding-exceptions-and-syntax-errors
Raising an Exception in Pythonhttps://realpython.com/python-exceptions/#raising-an-exception-in-python
Debugging During Development With asserthttps://realpython.com/python-exceptions/#debugging-during-development-with-assert
Handling Exceptions With the try and except Blockhttps://realpython.com/python-exceptions/#handling-exceptions-with-the-try-and-except-block
Proceeding After a Successful Try With elsehttps://realpython.com/python-exceptions/#proceeding-after-a-successful-try-with-else
Cleaning Up After Execution With finallyhttps://realpython.com/python-exceptions/#cleaning-up-after-execution-with-finally
Creating Custom Exceptions in Pythonhttps://realpython.com/python-exceptions/#creating-custom-exceptions-in-python
Conclusionhttps://realpython.com/python-exceptions/#conclusion
Frequently Asked Questionshttps://realpython.com/python-exceptions/#frequently-asked-questions
Remove adshttps://realpython.com/account/join/
Raising and Handling Python Exceptionshttps://realpython.com/courses/raising-handling-exceptions/
Click here to download the free sample codehttps://realpython.com/bonus/python-exceptions-code/
https://realpython.com/quizzes/python-exceptions/
Python Exceptions: An Introductionhttps://realpython.com/quizzes/python-exceptions/
https://realpython.com/python-exceptions/#understanding-exceptions-and-syntax-errors
Syntax errorshttps://realpython.com/invalid-syntax-python/
various built-in exceptionshttps://docs.python.org/3/library/exceptions.html
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-exceptions/#raising-an-exception-in-python
raisehttps://realpython.com/python-raise-exception/
https://files.realpython.com/media/raise.3931e8819e08.png
f-stringhttps://realpython.com/python-f-strings/
self-documenting expressionhttps://realpython.com/python-f-strings/#self-documenting-expressions-for-debugging
terminalhttps://realpython.com/terminal-commands/
REPLhttps://realpython.com/python-repl/
print()https://realpython.com/python-print/
https://realpython.com/python-exceptions/#debugging-during-development-with-assert
the try … except blockhttps://realpython.com/python-exceptions/#handling-exceptions-with-the-try-and-except-block
the assert keywordhttps://dbader.org/blog/python-assert-tutorial
https://files.realpython.com/media/assert.f6d344f0c0b4.png
the previous sectionhttps://realpython.com/python-exceptions/#raising-an-exception-in-python
conditional statementhttps://realpython.com/python-conditional-statements/
-O and -OO command line optionshttps://docs.python.org/3/using/cmdline.html#cmdoption-O
PYTHONOPTIMIZE environment variablehttps://docs.python.org/3/using/cmdline.html#envvar-PYTHONOPTIMIZE
raising an exceptionhttps://realpython.com/python-exceptions/#raising-an-exception-in-python
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-exceptions/#handling-exceptions-with-the-try-and-except-block
https://files.realpython.com/media/try_except.c94eabed2c59.png
many built-in exceptionshttps://docs.python.org/3/library/exceptions.html#concrete-exceptions
hierarchically relatedhttps://docs.python.org/3/library/exceptions.html#exception-hierarchy
warningshttps://docs.python.org/3/library/exceptions.html#warnings
OS exceptionshttps://docs.python.org/3/library/exceptions.html#os-exceptions
create a custom exceptionhttps://realpython.com/python-exceptions/#creating-custom-exceptions-in-python
loghttps://realpython.com/python-logging/
Python docshttps://docs.python.org/3/library/exceptions.html
Sourcehttps://docs.python.org/3/library/exceptions.html#FileNotFoundError
in this tutorialhttps://realpython.com/the-most-diabolical-python-antipattern/
multiple exceptionshttps://realpython.com/python-catch-multiple-exceptions/
Avoid using bare except clauseshttps://realpython.com/the-most-diabolical-python-antipattern/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-exceptions/#proceeding-after-a-successful-try-with-else
https://files.realpython.com/media/try_except_else.703aaeeb63d3.png
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-exceptions/#cleaning-up-after-execution-with-finally
https://files.realpython.com/media/try_except_else_finally.a7fac6c36c55.png
file handleshttps://realpython.com/why-close-file-python/
database connectionshttps://realpython.com/python-sql-libraries/
https://realpython.com/python-exceptions/#creating-custom-exceptions-in-python
RuntimeErrorhttps://docs.python.org/3/library/exceptions.html#RuntimeError
docstringhttps://realpython.com/documenting-python-code/
passhttps://realpython.com/python-pass/
the ellipsis (...)https://realpython.com/python-ellipsis/
How to Write Docstrings in Pythonhttps://realpython.com/how-to-write-docstrings-in-python/
Remove adshttps://realpython.com/account/join/
https://realpython.com/python-exceptions/#conclusion
Click here to download the free sample codehttps://realpython.com/bonus/python-exceptions-code/
Python’s Built-in Exceptions: A Walkthrough With Exampleshttps://realpython.com/python-built-in-exceptions/
Exception Groups and except*https://realpython.com/python311-exception-groups/#exception-groups-and-except-in-python-311
Python raise: Effectively Raising Exceptions in Your Codehttps://realpython.com/python-raise-exception/
How to Catch Multiple Exception in Pythonhttps://realpython.com/python-catch-multiple-exceptions/
Understanding the Python Tracebackhttps://realpython.com/python-traceback/
LBYL vs EAFP: Preventing or Handling Errors in Pythonhttps://realpython.com/python-lbyl-vs-eafp/
https://realpython.com/python-exceptions/#frequently-asked-questions
https://realpython.com/quizzes/python-exceptions/
Python Exceptions: An Introductionhttps://realpython.com/quizzes/python-exceptions/
https://realpython.com/feedback/survey/article/python-exceptions/liked/?from=article-footer
https://realpython.com/feedback/survey/article/python-exceptions/disliked/?from=article-footer
Raising and Handling Python Exceptionshttps://realpython.com/courses/raising-handling-exceptions/
https://realpython.com/team/svdklundert/
» More about Saidhttps://realpython.com/team/svdklundert/
https://realpython.com/team/acutenco/
Adrianahttps://realpython.com/team/acutenco/
https://realpython.com/team/bweleschuk/
Brendahttps://realpython.com/team/bweleschuk/
https://realpython.com/team/bzaczynski/
Bartoszhttps://realpython.com/team/bzaczynski/
https://realpython.com/team/gahjelle/
Geir Arnehttps://realpython.com/team/gahjelle/
https://realpython.com/team/jjablonski/
Joannahttps://realpython.com/team/jjablonski/
https://realpython.com/team/kfinegan/
Katehttps://realpython.com/team/kfinegan/
https://realpython.com/team/mbreuss/
Martinhttps://realpython.com/team/mbreuss/
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-exceptions
Level Up Your Python Skills »https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=python-exceptions
https://realpython.com/feedback/survey/article/python-exceptions/liked/?from=article-comments
https://realpython.com/feedback/survey/article/python-exceptions/disliked/?from=article-comments
LinkedInhttps://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fpython-exceptions%2F
Twitterhttps://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20Python%20Exceptions%3A%20An%20Introduction&url=https%3A%2F%2Frealpython.com%2Fpython-exceptions%2F
Blueskyhttps://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20Python%20Exceptions%3A%20An%20Introduction%20https%3A%2F%2Frealpython.com%2Fpython-exceptions%2F
Facebookhttps://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fpython-exceptions%2F
Get tips for asking good questionshttps://realpython.com/python-beginner-tips/#tip-9-ask-good-questions
get answers to common questions in our support portalhttps://support.realpython.com
Real Python Community Chathttps://realpython.com/community/
“Office Hours” Live Q&A Sessionhttps://realpython.com/office-hours/
basicshttps://realpython.com/tutorials/basics/
pythonhttps://realpython.com/tutorials/python/
Raising and Handling Python Exceptionshttps://realpython.com/courses/raising-handling-exceptions/
Defining Your Own Python Functionhttps://realpython.com/defining-your-own-python-function/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-exceptions
Python's raise: Effectively Raising Exceptions in Your Codehttps://realpython.com/python-raise-exception/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-exceptions
Python's Built-in Exceptions: A Walkthrough With Exampleshttps://realpython.com/python-built-in-exceptions/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-exceptions
Object-Oriented Programming (OOP) in Pythonhttps://realpython.com/python3-object-oriented-programming/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-exceptions
Logging in Pythonhttps://realpython.com/python-logging/?utm_source=realpython&utm_medium=web&utm_campaign=related-post&utm_content=python-exceptions
https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-exceptions%2F
Continue »https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fpython-exceptions%2F
Sign-Inhttps://realpython.com/account/login/?next=/python-exceptions/
Start Herehttps://realpython.com/start-here/
Learning Resourceshttps://realpython.com/search
Code Mentorhttps://realpython.com/mentor/
Python Referencehttps://realpython.com/ref/
Python Cheat Sheethttps://realpython.com/cheatsheets/python/
Support Centerhttps://support.realpython.com/
Learning Pathshttps://realpython.com/learning-paths/
Quizzes & Exerciseshttps://realpython.com/quizzes/
Browse Topicshttps://realpython.com/tutorials/all/
Live Courseshttps://realpython.com/live/
Bookshttps://realpython.com/books/
Podcasthttps://realpython.com/podcasts/rpp/
Newsletterhttps://realpython.com/newsletter/
Community Chathttps://realpython.com/community/
Office Hourshttps://realpython.com/office-hours/
Learner Storieshttps://realpython.com/learner-stories/
Plans & Pricinghttps://realpython.com/account/join/
Team Planshttps://realpython.com/account/join-team/
For Businesshttps://realpython.com/account/join-team/inquiry/
For Schoolshttps://realpython.com/account/join-team/education-inquiry/
Reviewshttps://realpython.com/learner-stories/
About Ushttps://realpython.com/about/
Teamhttps://realpython.com/team/
Mission & Valueshttps://realpython.com/mission/
Editorial Guidelineshttps://realpython.com/editorial-guidelines/
Sponsorshipshttps://realpython.com/sponsorships/
Careershttps://realpython.workable.com
Press Kithttps://realpython.com/media-kit/
Merchhttps://realpython.com/merch
https://www.youtube.com/realpython
https://x.com/realpython
https://www.linkedin.com/company/realpython-com
https://www.facebook.com/LearnRealPython
https://github.com/realpython/
Privacy Policyhttps://realpython.com/privacy-policy/
Terms of Usehttps://realpython.com/terms/
Securityhttps://realpython.com/security/
Contacthttps://realpython.com/contact/
https://realpython.com/

Viewport: width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover

Robots: max-image-preview:large


URLs of crawlers that visited me.