From a6607a7312f65e94bc91a8f04ab153747b157e44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 8 Jul 2019 21:42:52 +0200 Subject: [PATCH] Exceptions --- README.md | 25 +++++++++++++++++++++++++ index.html | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/README.md b/README.md index 20763d4..84f0bd8 100644 --- a/README.md +++ b/README.md @@ -1336,6 +1336,31 @@ Traceback (most recent call last): KeyboardInterrupt ``` +### Common Built-in Exceptions +```python +BaseException + +-- SystemExit # Raised by the sys.exit() function. + +-- KeyboardInterrupt # Raised when the user hits the interrupt key. + +-- Exception # User-defined exceptions should be derived from this class. + +-- StopIteration # Raised by next() when run on an empty iterator. + +-- ArithmeticError # Base class for arithmetic errors. + | +-- ZeroDivisionError # Raised when dividing by zero. + +-- AttributeError # Raised when an attribute is missing. + +-- EOFError # Raised by input() when it hits end-of-file condition. + +-- LookupError # Raised when a look-up on sequence or dict fails. + | +-- IndexError # Raised when a sequence index is out of range. + | +-- KeyError # Raised when a dictionary key is not found. + +-- NameError # Raised when a variable name is not found. + +-- OSError # Failures such as “file not found” or “disk full”. + | +-- FileNotFoundError # When a file or directory is requested but doesn't exist. + +-- RuntimeError # Raised by errors that don't fall in other categories. + | +-- RecursionError # Raised when the the maximum recursion depth is exceeded. + +-- TypeError # Raised when an argument is of wrong type. + +-- ValueError # When an argument is of right type but inappropriate value. + +-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails. +``` +* **Appropriate built-in exceptions to be risen by the user are: 'ValueError', 'TypeError' and 'RuntimeError'.** + Print ----- diff --git a/index.html b/index.html index 6f52b4b..e260b27 100644 --- a/index.html +++ b/index.html @@ -1229,6 +1229,31 @@ Traceback (most recent call last): File "<stdin>", line 2, in <module> KeyboardInterrupt +

Common Built-in Exceptions

+
BaseException
+ +-- SystemExit                   # Raised by the sys.exit() function.
+ +-- KeyboardInterrupt            # Raised when the user hits the interrupt key.
+ +-- Exception                    # User-defined exceptions should be derived from this class.
+      +-- StopIteration           # Raised by next() when run on an empty iterator.
+      +-- ArithmeticError         # Base class for arithmetic errors.
+      |    +-- ZeroDivisionError  # Raised when dividing by zero.
+      +-- AttributeError          # Raised when an attribute is missing.
+      +-- EOFError                # Raised by input() when it hits end-of-file condition.
+      +-- LookupError             # Raised when a look-up on sequence or dict fails.
+      |    +-- IndexError         # Raised when a sequence index is out of range.
+      |    +-- KeyError           # Raised when a dictionary key is not found.
+      +-- NameError               # Raised when a variable name is not found.
+      +-- OSError                 # Failures such as “file not found” or “disk full”.
+      |    +-- FileNotFoundError  # When a file or directory is requested but doesn't exist.
+      +-- RuntimeError            # Raised by errors that don't fall in other categories.
+      |    +-- RecursionError     # Raised when the the maximum recursion depth is exceeded.
+      +-- TypeError               # Raised when an argument is of wrong type.
+      +-- ValueError              # When an argument is of right type but inappropriate value.
+           +-- UnicodeError       # Raised when encoding/decoding strings from/to bytes fails. 
+
+

#Print

print(<el_1>, ..., sep=' ', end='\n', file=sys.stdout, flush=False)