diff --git a/README.md b/README.md index c2094ca..f5e6671 100644 --- a/README.md +++ b/README.md @@ -1407,6 +1407,18 @@ BaseException +-- UnicodeError # Raised when encoding/decoding strings from/to bytes fails. ``` +#### Collections and their execeptions: +```python ++-----------+------------+----------+----------+ +| | list | dict | set | ++-----------+------------+----------+----------+ +| getitem() | IndexError | KeyError | | +| pop() | IndexError | KeyError | KeyError | +| remove() | ValueError | | KeyError | +| index() | ValueError | | | ++-----------+------------+----------+----------+ +``` + ### User-defined Exceptions ```python class MyError(Exception): @@ -1431,8 +1443,7 @@ print(, ..., sep=' ', end='\n', file=sys.stdout, flush=False) >>> from pprint import pprint >>> pprint(dir()) ['__annotations__', - '__builtins__', - '__doc__', ...] + '__builtins__', ...] ``` @@ -1441,20 +1452,12 @@ Input * **Reads a line from user input or pipe if present.** * **Trailing newline gets stripped.** * **Prompt string is printed to the standard output before reading input.** +* **Raises EOFError when user hits EOF or input stream gets exhausted.** ```python = input(prompt=None) ``` -#### Prints lines until EOF: -```python -while True: - try: - print(input()) - except EOFError: - break -``` - Command Line Arguments ---------------------- diff --git a/index.html b/index.html index 19a94e3..e9d75c7 100644 --- a/index.html +++ b/index.html @@ -1309,6 +1309,16 @@ LogicOp = Enum('LogicOp', {Collections and their execeptions:
+-----------+------------+----------+----------+
+|           |    list    |   dict   |   set    |
++-----------+------------+----------+----------+
+| getitem() | IndexError | KeyError |          |
+| pop()     | IndexError | KeyError | KeyError |
+| remove()  | ValueError |          | KeyError |
+| index()   | ValueError |          |          |
++-----------+------------+----------+----------+
+
+

User-defined Exceptions

class MyError(Exception):
     pass
 
@@ -1326,25 +1336,18 @@ LogicOp = Enum('LogicOp', {Pretty Print
>>> from pprint import pprint
 >>> pprint(dir())
 ['__annotations__',
- '__builtins__',
- '__doc__', ...]
+ '__builtins__', ...]
 

#Input

  • Reads a line from user input or pipe if present.
  • Trailing newline gets stripped.
  • Prompt string is printed to the standard output before reading input.
  • +
  • Raises EOFError when user hits EOF or input stream gets exhausted.
<str> = input(prompt=None)
 
-

Prints lines until EOF:

while True:
-    try:
-        print(input())
-    except EOFError:
-        break
-
-

#Command Line Arguments

import sys
 script_name = sys.argv[0]
 arguments   = sys.argv[1:]
diff --git a/web/script_2.js b/web/script_2.js
index f254969..a6a9f63 100644
--- a/web/script_2.js
+++ b/web/script_2.js
@@ -162,6 +162,21 @@ const DIAGRAM_9_B =
   "┃ escapechar       │     None  │     None  │      None    ┃\n" +
   "┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n";
 
+const DIAGRAM_10_A = 
+  '+-----------+------------+----------+----------+\n' +
+  '|           |    list    |   dict   |   set    |\n' +
+  '+-----------+------------+----------+----------+\n';
+
+const DIAGRAM_10_B = 
+  '┏━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━┓\n' +
+  '┃           │    list    │   dict   │   set    ┃\n' +
+  '┠───────────┼────────────┼──────────┼──────────┨\n' +
+  '┃ getitem() │ IndexError │ KeyError │          ┃\n' +
+  '┃ pop()     │ IndexError │ KeyError │ KeyError ┃\n' +
+  '┃ remove()  │ ValueError │          │ KeyError ┃\n' +
+  '┃ index()   │ ValueError │          │          ┃\n' +
+  '┗━━━━━━━━━━━┷━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━┛\n';
+
 
 // isFontAvailable:
 (function(d){function c(c){b.style.fontFamily=c;e.appendChild(b);f=b.clientWidth;e.removeChild(b);return f}var f,e=d.body,b=d.createElement("span");b.innerHTML=Array(100).join("wi");b.style.cssText=["position:absolute","width:auto","font-size:128px","left:-99999px"].join(" !important;");var g=c("monospace"),h=c("serif"),k=c("sans-serif");window.isFontAvailable=function(b){return g!==c(b+",monospace")||k!==c(b+",sans-serif")||h!==c(b+",serif")}})(document);
@@ -176,6 +191,7 @@ if (isFontAvailable('Menlo')) {
   $(`code:contains(${DIAGRAM_7_A})`).html(DIAGRAM_7_B);
   $(`code:contains(${DIAGRAM_8_A})`).html(DIAGRAM_8_B);
   $(`code:contains(${DIAGRAM_9_A})`).html(DIAGRAM_9_B);
+  $(`code:contains(${DIAGRAM_10_A})`).html(DIAGRAM_10_B);
 }
 
 var isMobile = false;