|
|
@ -1229,6 +1229,31 @@ Traceback (most recent call last): |
|
|
|
File <span class="hljs-string">"<stdin>"</span>, line <span class="hljs-number">2</span>, <span class="hljs-keyword">in</span> <module> |
|
|
|
KeyboardInterrupt |
|
|
|
</code></pre> |
|
|
|
<h3 id="commonbuiltinexceptions">Common Built-in Exceptions</h3> |
|
|
|
<pre><code class="python language-python hljs">BaseException |
|
|
|
+-- SystemExit <span class="hljs-comment"># Raised by the sys.exit() function.</span> |
|
|
|
+-- KeyboardInterrupt <span class="hljs-comment"># Raised when the user hits the interrupt key.</span> |
|
|
|
+-- Exception <span class="hljs-comment"># User-defined exceptions should be derived from this class.</span> |
|
|
|
+-- StopIteration <span class="hljs-comment"># Raised by next() when run on an empty iterator.</span> |
|
|
|
+-- ArithmeticError <span class="hljs-comment"># Base class for arithmetic errors.</span> |
|
|
|
| +-- ZeroDivisionError <span class="hljs-comment"># Raised when dividing by zero.</span> |
|
|
|
+-- AttributeError <span class="hljs-comment"># Raised when an attribute is missing.</span> |
|
|
|
+-- EOFError <span class="hljs-comment"># Raised by input() when it hits end-of-file condition.</span> |
|
|
|
+-- LookupError <span class="hljs-comment"># Raised when a look-up on sequence or dict fails.</span> |
|
|
|
| +-- IndexError <span class="hljs-comment"># Raised when a sequence index is out of range.</span> |
|
|
|
| +-- KeyError <span class="hljs-comment"># Raised when a dictionary key is not found.</span> |
|
|
|
+-- NameError <span class="hljs-comment"># Raised when a variable name is not found.</span> |
|
|
|
+-- OSError <span class="hljs-comment"># Failures such as “file not found” or “disk full”.</span> |
|
|
|
| +-- FileNotFoundError <span class="hljs-comment"># When a file or directory is requested but doesn't exist.</span> |
|
|
|
+-- RuntimeError <span class="hljs-comment"># Raised by errors that don't fall in other categories.</span> |
|
|
|
| +-- RecursionError <span class="hljs-comment"># Raised when the the maximum recursion depth is exceeded.</span> |
|
|
|
+-- TypeError <span class="hljs-comment"># Raised when an argument is of wrong type.</span> |
|
|
|
+-- ValueError <span class="hljs-comment"># When an argument is of right type but inappropriate value.</span> |
|
|
|
+-- UnicodeError <span class="hljs-comment"># Raised when encoding/decoding strings from/to bytes fails. </span> |
|
|
|
</code></pre> |
|
|
|
<ul> |
|
|
|
<li><strong>Appropriate built-in exceptions to be risen by the user are: 'ValueError', 'TypeError' and 'RuntimeError'.</strong></li> |
|
|
|
</ul> |
|
|
|
<h2 id="print"><a href="#print" name="print">#</a>Print</h2> |
|
|
|
<pre><code class="python language-python hljs">print(<el_1>, ..., sep=<span class="hljs-string">' '</span>, end=<span class="hljs-string">'\n'</span>, file=sys.stdout, flush=<span class="hljs-keyword">False</span>) |
|
|
|
</code></pre> |
|
|
|