Skip to content

Commit a6607a7

Browse files
committed
Exceptions
1 parent 1074b75 commit a6607a7

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,31 @@ Traceback (most recent call last):
13361336
KeyboardInterrupt
13371337
```
13381338

1339+
### Common Built-in Exceptions
1340+
```python
1341+
BaseException
1342+
+-- SystemExit # Raised by the sys.exit() function.
1343+
+-- KeyboardInterrupt # Raised when the user hits the interrupt key.
1344+
+-- Exception # User-defined exceptions should be derived from this class.
1345+
+-- StopIteration # Raised by next() when run on an empty iterator.
1346+
+-- ArithmeticError # Base class for arithmetic errors.
1347+
| +-- ZeroDivisionError # Raised when dividing by zero.
1348+
+-- AttributeError # Raised when an attribute is missing.
1349+
+-- EOFError # Raised by input() when it hits end-of-file condition.
1350+
+-- LookupError # Raised when a look-up on sequence or dict fails.
1351+
| +-- IndexError # Raised when a sequence index is out of range.
1352+
| +-- KeyError # Raised when a dictionary key is not found.
1353+
+-- NameError # Raised when a variable name is not found.
1354+
+-- OSError # Failures such as “file not found” or “disk full”.
1355+
| +-- FileNotFoundError # When a file or directory is requested but doesn't exist.
1356+
+-- RuntimeError # Raised by errors that don't fall in other categories.
1357+
| +-- RecursionError # Raised when the the maximum recursion depth is exceeded.
1358+
+-- TypeError # Raised when an argument is of wrong type.
1359+
+-- ValueError # When an argument is of right type but inappropriate value.
1360+
+-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails.
1361+
```
1362+
* **Appropriate built-in exceptions to be risen by the user are: 'ValueError', 'TypeError' and 'RuntimeError'.**
1363+
13391364

13401365
Print
13411366
-----

index.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,31 @@ <h3 id="finally">Finally</h3>
12291229
File <span class="hljs-string">"&lt;stdin&gt;"</span>, line <span class="hljs-number">2</span>, <span class="hljs-keyword">in</span> &lt;module&gt;
12301230
KeyboardInterrupt
12311231
</code></pre>
1232+
<h3 id="commonbuiltinexceptions">Common Built-in Exceptions</h3>
1233+
<pre><code class="python language-python hljs">BaseException
1234+
+-- SystemExit <span class="hljs-comment"># Raised by the sys.exit() function.</span>
1235+
+-- KeyboardInterrupt <span class="hljs-comment"># Raised when the user hits the interrupt key.</span>
1236+
+-- Exception <span class="hljs-comment"># User-defined exceptions should be derived from this class.</span>
1237+
+-- StopIteration <span class="hljs-comment"># Raised by next() when run on an empty iterator.</span>
1238+
+-- ArithmeticError <span class="hljs-comment"># Base class for arithmetic errors.</span>
1239+
| +-- ZeroDivisionError <span class="hljs-comment"># Raised when dividing by zero.</span>
1240+
+-- AttributeError <span class="hljs-comment"># Raised when an attribute is missing.</span>
1241+
+-- EOFError <span class="hljs-comment"># Raised by input() when it hits end-of-file condition.</span>
1242+
+-- LookupError <span class="hljs-comment"># Raised when a look-up on sequence or dict fails.</span>
1243+
| +-- IndexError <span class="hljs-comment"># Raised when a sequence index is out of range.</span>
1244+
| +-- KeyError <span class="hljs-comment"># Raised when a dictionary key is not found.</span>
1245+
+-- NameError <span class="hljs-comment"># Raised when a variable name is not found.</span>
1246+
+-- OSError <span class="hljs-comment"># Failures such as “file not found” or “disk full”.</span>
1247+
| +-- FileNotFoundError <span class="hljs-comment"># When a file or directory is requested but doesn't exist.</span>
1248+
+-- RuntimeError <span class="hljs-comment"># Raised by errors that don't fall in other categories.</span>
1249+
| +-- RecursionError <span class="hljs-comment"># Raised when the the maximum recursion depth is exceeded.</span>
1250+
+-- TypeError <span class="hljs-comment"># Raised when an argument is of wrong type.</span>
1251+
+-- ValueError <span class="hljs-comment"># When an argument is of right type but inappropriate value.</span>
1252+
+-- UnicodeError <span class="hljs-comment"># Raised when encoding/decoding strings from/to bytes fails. </span>
1253+
</code></pre>
1254+
<ul>
1255+
<li><strong>Appropriate built-in exceptions to be risen by the user are: 'ValueError', 'TypeError' and 'RuntimeError'.</strong></li>
1256+
</ul>
12321257
<h2 id="print"><a href="#print" name="print">#</a>Print</h2>
12331258
<pre><code class="python language-python hljs">print(&lt;el_1&gt;, ..., sep=<span class="hljs-string">' '</span>, end=<span class="hljs-string">'\n'</span>, file=sys.stdout, flush=<span class="hljs-keyword">False</span>)
12341259
</code></pre>

0 commit comments

Comments
 (0)