{"id":3093,"date":"2021-11-27T16:59:50","date_gmt":"2021-11-27T16:59:50","guid":{"rendered":"https:\/\/www.pythontutorial.net\/?page_id=3093"},"modified":"2025-03-28T03:42:17","modified_gmt":"2025-03-28T03:42:17","slug":"python-raise-from","status":"publish","type":"page","link":"https:\/\/www.pythontutorial.net\/python-oop\/python-raise-from\/","title":{"rendered":"Python raise from"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the Python raise from statement to raise an exception with extra information.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-python-raise-from-statement'>Introduction to the Python raise from statement <a href=\"#introduction-to-the-python-raise-from-statement\" class=\"anchor\" id=\"introduction-to-the-python-raise-from-statement\" title=\"Anchor for Introduction to the Python raise from statement\">#<\/a><\/h2>\n\n\n\n<p>The <code>raise from<\/code> statement has the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">raise<\/span> &lt;ExceptionType&gt; <span class=\"hljs-keyword\">from<\/span> &lt;cause&gt;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Technically, it&#8217;s equivalent to the following:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">ex = ExceptionType\nex.__cause__ = cause\n<span class=\"hljs-keyword\">raise<\/span> ex<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>By default, the <code>__cause__<\/code> attribute on <a href=\"https:\/\/www.pythontutorial.net\/python-oop\/python-exceptions\/\">exception<\/a> objects is always initialized to <code><a href=\"https:\/\/www.pythontutorial.net\/advanced-python\/python-none\/\">None<\/a><\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='python-raise-from-statement-example'>Python raise from statement example <a href=\"#python-raise-from-statement-example\" class=\"anchor\" id=\"python-raise-from-statement-example\" title=\"Anchor for Python raise from statement example\">#<\/a><\/h2>\n\n\n\n<p>The following <code>divide()<\/code> function divides a number by another and returns the result of the division:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError <span class=\"hljs-keyword\">as<\/span> ex:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>divide()<\/code> function has an exception handler that catches the <code>ZeroDivisionError<\/code> exception. Inside the handler, we raise a new <code>ValueError<\/code> exception. <\/p>\n\n\n\n<p>If you pass zero to the second argument of the <code>divide()<\/code> function: <\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError <span class=\"hljs-keyword\">as<\/span> ex:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> ex\n\n\ndivide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>you&#8217;ll get the following stack trace:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Traceback (most recent call last):\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-keyword\">in<\/span> divide\n    <span class=\"hljs-keyword\">return<\/span> a \/ b\nZeroDivisionError: division by zero\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">8<\/span>, <span class=\"hljs-keyword\">in<\/span> &lt;module&gt;\n    divide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-keyword\">in<\/span> divide\n    <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>)\nValueError: b must <span class=\"hljs-keyword\">not<\/span> be zero<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The import message is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">During handling of the above exception, another exception occurred:<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It means that while you were handling the <code>ZeroDivisionError<\/code> exception, the <code>ValueError<\/code> exception occurred.<\/p>\n\n\n\n<p>To instruct Python that you want to modify and forward the <code>ZeroDivisionError<\/code> exception, you can use the <code>raise from<\/code> statement like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError <span class=\"hljs-keyword\">as<\/span> ex:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> ex\n\ndivide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>When you run the code, you&#8217;ll get the following stack trace:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Traceback (most recent call last):\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-keyword\">in<\/span> divide\n    <span class=\"hljs-keyword\">return<\/span> a \/ b\nZeroDivisionError: division by zero\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">8<\/span>, <span class=\"hljs-keyword\">in<\/span> &lt;module&gt;\n    divide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-keyword\">in<\/span> divide\n    <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> ex\nValueError: b must <span class=\"hljs-keyword\">not<\/span> be zero<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, you receive the <code>ValueError<\/code> exception with a cause added to the __cause__ attribute of the exception object. <\/p>\n\n\n\n<p>The following modifies the above code to show the <code>__cause__<\/code> attribute of the <code>ValueError<\/code> exception:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError <span class=\"hljs-keyword\">as<\/span> ex:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> ex\n\n\n<span class=\"hljs-keyword\">try<\/span>:\n    divide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)\n<span class=\"hljs-keyword\">except<\/span> ValueError <span class=\"hljs-keyword\">as<\/span> ex:\n    print(<span class=\"hljs-string\">'cause:'<\/span>, ex.__cause__)\n    print(<span class=\"hljs-string\">'exception:'<\/span>, ex)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cause: division by zero\nexception: b must <span class=\"hljs-keyword\">not<\/span> be zero<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='python-raise-exception-from-none'>Python raise exception from None <a href=\"#python-raise-exception-from-none\" class=\"anchor\" id=\"python-raise-exception-from-none\" title=\"Anchor for Python raise exception from None\">#<\/a><\/h2>\n\n\n\n<p>If the cause of the exception is not important, you can omit the cause by using the <code>raise exception from None<\/code> statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-keyword\">raise<\/span> &lt;ExceptionType&gt; <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-literal\">None<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p> For example, you can hide the cause of the <code>ValueError<\/code> exception in the <code>divide()<\/code> function as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-literal\">None<\/span>\n\n\n<span class=\"hljs-keyword\">try<\/span>:\n    divide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)\n<span class=\"hljs-keyword\">except<\/span> ValueError <span class=\"hljs-keyword\">as<\/span> ex:\n    print(<span class=\"hljs-string\">'cause:'<\/span>, ex.__cause__)\n    print(<span class=\"hljs-string\">'exception:'<\/span>, ex)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><a href=\"https:\/\/www.pythontutorial.net\/playground\/?q=ZGVmIGRpdmlkZShhLCBiKToKICAgIHRyeToKICAgICAgICByZXR1cm4gYSAvIGIKICAgIGV4Y2VwdCBaZXJvRGl2aXNpb25FcnJvcjoKICAgICAgICByYWlzZSBWYWx1ZUVycm9yKCdiIG11c3Qgbm90IGJlIHplcm8nKSBmcm9tIE5vbmUKCgp0cnk6CiAgICBkaXZpZGUoMTAsIDApCmV4Y2VwdCBWYWx1ZUVycm9yIGFzIGV4OgogICAgcHJpbnQoJ2NhdXNlOicsIGV4Ll9fY2F1c2VfXykKICAgIHByaW50KCdleGNlcHRpb246JywgZXgp\" target=\"_blank\" rel=\"noreferrer noopener\">Try it<\/a><\/p>\n\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">cause: <span class=\"hljs-literal\">None<\/span>\nexception: b must <span class=\"hljs-keyword\">not<\/span> be zero<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, the <code>__cause__<\/code> is <code>None<\/code>. Also, the <code>divide()<\/code> function raises the <code>ValueError<\/code> exception without any additional information.<\/p>\n\n\n\n<p>If you remove the <code>try<\/code> statement in the code that calls the <code>divide()<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">divide<\/span><span class=\"hljs-params\">(a, b)<\/span>:<\/span>\n    <span class=\"hljs-keyword\">try<\/span>:\n        <span class=\"hljs-keyword\">return<\/span> a \/ b\n    <span class=\"hljs-keyword\">except<\/span> ZeroDivisionError:\n        <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-literal\">None<\/span>\n\n\ndivide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>you&#8217;ll get the following stack trace:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"Python\" data-shcb-language-slug=\"python\"><span><code class=\"hljs language-python\">Traceback (most recent call last):\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">8<\/span>, <span class=\"hljs-keyword\">in<\/span> &lt;module&gt;\n    divide(<span class=\"hljs-number\">10<\/span>, <span class=\"hljs-number\">0<\/span>)\n  File <span class=\"hljs-string\">\"c:\/python\/app.py\"<\/span>, line <span class=\"hljs-number\">5<\/span>, <span class=\"hljs-keyword\">in<\/span> divide\n    <span class=\"hljs-keyword\">raise<\/span> ValueError(<span class=\"hljs-string\">'b must not be zero'<\/span>) <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-literal\">None<\/span>\nValueError: b must <span class=\"hljs-keyword\">not<\/span> be zero<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">Python<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">python<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the Python <code>raise from<\/code> statement to modify and forward an existing exception.<\/li>\n\n\n\n<li>Use the <code>raise exception from None<\/code>  statment to hide the cause of the exception.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3093\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-oop\/python-raise-from\/\"\n\t\t\t\tdata-post-title=\"Python raise from\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3093\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pythontutorial.net\/python-oop\/python-raise-from\/\"\n\t\t\t\tdata-post-title=\"Python raise from\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\t\t\t<input type=\"button\" name=\"wth-submit\" class=\"wth-btn wth-btn-submit\" id=\"wth-submit\" \/>\n\t\t\t<input type=\"button\" class=\"wth-btn wth-btn-cancel\" value=\"Cancel\" \/>\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to use the Python raise from statement to raise an exception with extra information.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":417,"menu_order":48,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3093","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/3093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/comments?post=3093"}],"version-history":[{"count":1,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/3093\/revisions"}],"predecessor-version":[{"id":7186,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/3093\/revisions\/7186"}],"up":[{"embeddable":true,"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/pages\/417"}],"wp:attachment":[{"href":"https:\/\/www.pythontutorial.net\/wp-json\/wp\/v2\/media?parent=3093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}