From 09a87b206ba9cd9833df336e9dc9dd7c64654bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 11 Mar 2024 05:14:13 +0100 Subject: [PATCH 001/332] Profiling --- README.md | 14 +++++++------- index.html | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d50554c7f..4496575d0 100644 --- a/README.md +++ b/README.md @@ -2620,13 +2620,13 @@ Line # Hits Time Per Hit % Time Line Contents ``` ### Call and Flame Graphs -```text -$ apt/brew install graphviz && pip3 install gprof2dot snakeviz -$ tail --lines=4 test.py > test.py -$ python3 -m cProfile -o test.prof test.py -$ gprof2dot --format=pstats test.prof | dot -T png -o test.png -$ xdg-open/open test.png -$ snakeviz test.prof +```bash +$ apt/brew install graphviz && pip3 install gprof2dot snakeviz # Or download installer. +$ tail --lines=4 test.py > test.py # Removes first line. +$ python3 -m cProfile -o test.prof test.py # Runs built-in profiler. +$ gprof2dot --format=pstats test.prof | dot -T png -o test.png # Generates call graph. +$ xdg-open/open test.png # Displays call graph. +$ snakeviz test.prof # Displays flame graph. ``` ### Sampling and Memory Profilers diff --git a/index.html b/index.html index fe8a3e201..00a550a35 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -2157,12 +2157,12 @@

Format

Call and Flame Graphs

$ apt/brew install graphviz && pip3 install gprof2dot snakeviz
-$ tail --lines=4 test.py > test.py
-$ python3 -m cProfile -o test.prof test.py
-$ gprof2dot --format=pstats test.prof | dot -T png -o test.png
-$ xdg-open/open test.png
-$ snakeviz test.prof
+

Call and Flame Graphs

$ apt/brew install graphviz && pip3 install gprof2dot snakeviz  # Or download installer.
+$ tail --lines=4 test.py > test.py                              # Removes first line.
+$ python3 -m cProfile -o test.prof test.py                      # Runs built-in profiler.
+$ gprof2dot --format=pstats test.prof | dot -T png -o test.png  # Generates call graph.
+$ xdg-open/open test.png                                        # Displays call graph.
+$ snakeviz test.prof                                            # Displays flame graph.
 

Sampling and Memory Profilers

┏━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━┓
@@ -2935,7 +2935,7 @@ 

Format

Type Annotations

  • They add type hints to variables, arguments and functions ('def f() -> <type>:').
  • -
  • Are ignored by CPython interpreter, but used by tools such as mypy, Pydantic and Cython.
  • +
  • Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.
from collections import abc
 
 <name>: <type> [| ...] [= <obj>]
-<name>: list/set[<type>] [= <obj>]
-<name>: abc.Iterable/abc.Sequence[<type>] [= <obj>]
+<name>: list/set/abc.Iterable/abc.Sequence[<type>] [= <obj>]
 <name>: dict/tuple[<type>, ...] [= <obj>]
 
diff --git a/pdf/remove_links.py b/pdf/remove_links.py index 95fd91386..bb4733845 100755 --- a/pdf/remove_links.py +++ b/pdf/remove_links.py @@ -11,6 +11,7 @@ 'Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.': 'Module \'operator\' (p. 31) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions (p. 11) above.', 'Adding \'!r\' to the expression converts object to string by calling its repr() method.': 'Adding \'!r\' to the expression converts object to string by calling its repr() method.', 'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable, but is usually implemented as a function that returns a closure.', + 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.': 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.', 'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.': 'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.', 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.': 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.', 'Function field() is needed because \'<attr_name>: list = []\' would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable.': 'Function field() is needed because \'<attr_name>: list = []\' would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable (p. 17).', @@ -25,7 +26,7 @@ 'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments/results must be pickable.': 'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments/results must be pickable.', 'ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be pickable. Queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters.': 'ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be pickable. Queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters.', 'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes.': 'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes (p. 30).', - 'A WSGI server like Waitress and a HTTP server such as Nginx are needed to run globally.': 'A WSGI server like Waitress and a HTTP server such as Nginx are needed to run globally.', + 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.': 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.', 'The "latest and greatest" profiler that can also monitor GPU usage is called Scalene.': 'The "latest and greatest" profiler that can also monitor GPU usage is called Scalene.', } From 794a3599aa930730a79ca2bebc7b589df5f362c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 12 Mar 2024 06:21:49 +0100 Subject: [PATCH 003/332] Regex --- README.md | 33 ++++++++++++++++----------------- index.html | 37 ++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 5031fd19c..a5e167fe3 100644 --- a/README.md +++ b/README.md @@ -351,36 +351,35 @@ Regex ```python import re - = re.sub(, new, text, count=0) # Substitutes all occurrences with 'new'. - = re.findall(, text) # Returns all occurrences as strings. - = re.split(, text, maxsplit=0) # Add brackets around regex to include matches. - = re.search(, text) # First occurrence of the pattern or None. - = re.match(, text) # Searches only at the beginning of the text. - = re.finditer(, text) # Returns all occurrences as Match objects. + = re.sub(r'', new, text, count=0) # Substitutes all occurrences with 'new'. + = re.findall(r'', text) # Returns all occurrences as strings. + = re.split(r'', text, maxsplit=0) # Add brackets around regex to keep matches. + = re.search(r'', text) # First occurrence of the pattern or None. + = re.match(r'', text) # Searches only at the beginning of the text. + = re.finditer(r'', text) # Returns all occurrences as Match objects. ``` -* **Argument 'new' can be a function that accepts a Match object and returns a string.** +* **Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals.** +* **Argument 'new' of re.sub() can be a function that accepts a Match object and returns a str.** * **Argument `'flags=re.IGNORECASE'` can be used with all functions.** * **Argument `'flags=re.MULTILINE'` makes `'^'` and `'$'` match the start/end of each line.** * **Argument `'flags=re.DOTALL'` makes `'.'` also accept the `'\n'`.** -* **Use `r'\1'` or `'\\1'` for backreference (`'\1'` returns a character with octal code 1).** -* **Add `'?'` after `'*'` and `'+'` to make them non-greedy.** * **`'re.compile()'` returns a Pattern object with methods sub(), findall(), …** ### Match Object ```python - = .group() # Returns the whole match. Also group(0). - = .group(1) # Returns part inside the first brackets. - = .groups() # Returns all bracketed parts. - = .start() # Returns start index of the match. - = .end() # Returns exclusive end index of the match. + = .group() # Returns the whole match. Also group(0). + = .group(1) # Returns part inside the first brackets. + = .groups() # Returns all bracketed parts. + = .start() # Returns start index of the match. + = .end() # Returns exclusive end index of the match. ``` ### Special Sequences ```python -'\d' == '[0-9]' # Also [०-९…]. Matches a decimal character. -'\w' == '[a-zA-Z0-9_]' # Also [ª²³…]. Matches an alphanumeric or _. -'\s' == '[ \t\n\r\f\v]' # Also [\x1c-\x1f…]. Matches a whitespace. +'\d' == '[0-9]' # Also [०-९…]. Matches a decimal character. +'\w' == '[a-zA-Z0-9_]' # Also [ª²³…]. Matches an alphanumeric or _. +'\s' == '[ \t\n\r\f\v]' # Also [\x1c-\x1f…]. Matches a whitespace. ``` * **By default, decimal characters, alphanumerics and whitespaces from all alphabets are matched unless `'flags=re.ASCII'` argument is used.** diff --git a/index.html b/index.html index f2849e4a2..0541e71c1 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -325,34 +325,33 @@

#Regex

Functions for regular expression matching.

import re
-<str>   = re.sub(<regex>, new, text, count=0)  # Substitutes all occurrences with 'new'.
-<list>  = re.findall(<regex>, text)            # Returns all occurrences as strings.
-<list>  = re.split(<regex>, text, maxsplit=0)  # Add brackets around regex to include matches.
-<Match> = re.search(<regex>, text)             # First occurrence of the pattern or None.
-<Match> = re.match(<regex>, text)              # Searches only at the beginning of the text.
-<iter>  = re.finditer(<regex>, text)           # Returns all occurrences as Match objects.
+<str>   = re.sub(r'<regex>', new, text, count=0)  # Substitutes all occurrences with 'new'.
+<list>  = re.findall(r'<regex>', text)            # Returns all occurrences as strings.
+<list>  = re.split(r'<regex>', text, maxsplit=0)  # Add brackets around regex to keep matches.
+<Match> = re.search(r'<regex>', text)             # First occurrence of the pattern or None.
+<Match> = re.match(r'<regex>', text)              # Searches only at the beginning of the text.
+<iter>  = re.finditer(r'<regex>', text)           # Returns all occurrences as Match objects.
 
-

Match Object

<str>   = <Match>.group()                      # Returns the whole match. Also group(0).
-<str>   = <Match>.group(1)                     # Returns part inside the first brackets.
-<tuple> = <Match>.groups()                     # Returns all bracketed parts.
-<int>   = <Match>.start()                      # Returns start index of the match.
-<int>   = <Match>.end()                        # Returns exclusive end index of the match.
+

Match Object

<str>   = <Match>.group()                         # Returns the whole match. Also group(0).
+<str>   = <Match>.group(1)                        # Returns part inside the first brackets.
+<tuple> = <Match>.groups()                        # Returns all bracketed parts.
+<int>   = <Match>.start()                         # Returns start index of the match.
+<int>   = <Match>.end()                           # Returns exclusive end index of the match.
 
-

Special Sequences

'\d' == '[0-9]'                                # Also [०-९…]. Matches a decimal character.
-'\w' == '[a-zA-Z0-9_]'                         # Also [ª²³…]. Matches an alphanumeric or _.
-'\s' == '[ \t\n\r\f\v]'                        # Also [\x1c-\x1f…]. Matches a whitespace.
+

Special Sequences

'\d' == '[0-9]'                                   # Also [०-९…]. Matches a decimal character.
+'\w' == '[a-zA-Z0-9_]'                            # Also [ª²³…]. Matches an alphanumeric or _.
+'\s' == '[ \t\n\r\f\v]'                           # Also [\x1c-\x1f…]. Matches a whitespace.
 
    @@ -2934,7 +2933,7 @@

    Format

    From 11eaa68d9b7c5245bcf0ac2aaf9be242e455f1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 12 Mar 2024 09:16:48 +0100 Subject: [PATCH 005/332] Updated FAQ --- web/faq.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/faq.html b/web/faq.html index 1a7d8be04..77ad0301b 100644 --- a/web/faq.html +++ b/web/faq.html @@ -1,5 +1,7 @@ -
    Python 2 or Python 3?
    -    Python 3.8 (or higher). +
    Which Python version is this for?
    +    Everything should work in the latest Python version, that is 3.13.

    +    Every feature that requires version higher than 3.8 has that mentioned in comments or brackets. There are only six such features, four requiring 3.9, and two requiring 3.10.

    +    As of 12th March 2024, the only libraries whose latest version requires Python version higher than 3.8 are: numpy, pandas and matplotlib. They all require Python 3.9.

    What is the best way to use it?
    From 51d6301a6288968f791c19b92757f2befd646e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 12 Mar 2024 09:46:18 +0100 Subject: [PATCH 006/332] Updated FAQ --- web/faq.html | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/faq.html b/web/faq.html index 77ad0301b..a95cb8de9 100644 --- a/web/faq.html +++ b/web/faq.html @@ -1,7 +1,6 @@
    Which Python version is this for?
    -    Everything should work in the latest Python version, that is 3.13.

    -    Every feature that requires version higher than 3.8 has that mentioned in comments or brackets. There are only six such features, four requiring 3.9, and two requiring 3.10.

    -    As of 12th March 2024, the only libraries whose latest version requires Python version higher than 3.8 are: numpy, pandas and matplotlib. They all require Python 3.9. +    Everything should work in the latest Python version, which is 3.13. Every feature that requires version higher than 3.8 has that mentioned in comments or brackets. There are only six such features, four requiring 3.9, and two requiring 3.10.

    +    As of 12th March 2024, the only libraries whose latest version requires Python version higher than 3.8 are: numpy, pandas and matplotlib. They all require Python 3.9. This cheatsheet covers pandas library version 2.0 or higher which was released on 3rd April 2023.

    What is the best way to use it?
    From 3366b2f0cbb7a6ebf3077552ad7e6783be431360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 12 Mar 2024 22:11:38 +0100 Subject: [PATCH 007/332] Updated FAQ --- web/faq.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/faq.html b/web/faq.html index a95cb8de9..aaa303c5f 100644 --- a/web/faq.html +++ b/web/faq.html @@ -3,9 +3,10 @@     As of 12th March 2024, the only libraries whose latest version requires Python version higher than 3.8 are: numpy, pandas and matplotlib. They all require Python 3.9. This cheatsheet covers pandas library version 2.0 or higher which was released on 3rd April 2023.

    -
    What is the best way to use it?
    -    I keep the text file open on separate desktop at all times. It is also in a different text editor than the one I usually use, so it's easier to switch to with Ctrl+↹ / ⌘↹. Cheatsheet consists of minimal text and short examples so things are easy to find with Ctrl+F / ⌘F. If you're on the webpage, searching for '#<name>' will only search for the titles.

    -    I also keep the Python console open at all times to test little snippets of code, to check out the available functions of a module using code completion and above all, to use help(<module/object/function/type/str>) command. If something is still unclear, then I search the Python docs by googling 'python docs <module/function>'. +
    How to use it?
    +    This cheatsheet consists of minimal text and short examples so things are easy to find with Ctrl+F / ⌘F. If you're on the webpage, searching for '#<name>' will only search for the titles. To get a link to a specific section click the grey hashtag next to the section's title before copying the address. To search for titles in the text editor use ^<name> with enabled regular expressions option.

    +    I also keep the Python console open at all times to test little snippets of code, to check out the available functions of a module using code completion and above all, to use help(<module/object/function/type/str>) command. If something is still unclear, then I search the Python docs by googling 'python docs <module/function>'.

    +    Recently I started using the ptpython REPL (Python console). It supports multiline editing, syntax validation, IDE-like autocompletion and syntax highlighting. It can be installed with pip3 install ptpython.

    What does the '<type>' signify?
    From ce98a71f65e8295caad38900c2d8b4fc75789436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 15 Mar 2024 02:00:48 +0100 Subject: [PATCH 008/332] Updated FAQ --- index.html | 4 ++-- web/faq.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 26c9a21b4..c6eb51c20 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
    - +
    @@ -2933,7 +2933,7 @@

    Format

Table of required and automatically available special methods:

┏━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓
 ┃            │  Iterable  │ Collection │  Sequence  │ abc.Sequence ┃
 ┠────────────┼────────────┼────────────┼────────────┼──────────────┨
-┃ iter()     │     !      │     !      │     ✓      │      ✓       ┃
+┃ iter()     │     !*     │     !      │     ✓      │      ✓       ┃
 ┃ contains() │     ✓      │     ✓      │     ✓      │      ✓       ┃
 ┃ len()      │            │     !      │     !      │      !       ┃
 ┃ getitem()  │            │            │     !      │      !       ┃
@@ -1131,7 +1131,8 @@
 
    -
  • Other ABCs that generate missing methods are: MutableSequence, Set, MutableSet, Mapping and MutableMapping.
  • +
  • Method iter() is required for 'isinstance(<obj>, abc.Iterable)' to return True, however any object with getitem() will work just fine with any code expecting an iterable.
  • +
  • Abstract base classes that generate missing methods when extended are: Sequence, MutableSequence, Set, MutableSet, Mapping and MutableMapping.
  • Names of their required methods are stored in '<abc>.__abstractmethods__'.

#Enum

from enum import Enum, auto
diff --git a/parse.js b/parse.js
index d99d15cf3..cd32aa2d6 100755
--- a/parse.js
+++ b/parse.js
@@ -410,7 +410,7 @@ const DIAGRAM_6_B =
   '┏━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
   '┃            │  Iterable  │ Collection │  Sequence  │ abc.Sequence ┃\n' +
   '┠────────────┼────────────┼────────────┼────────────┼──────────────┨\n' +
-  '┃ iter()     │     !      │     !      │     ✓      │      ✓       ┃\n' +
+  '┃ iter()     │     !*     │     !      │     ✓      │      ✓       ┃\n' +
   '┃ contains() │     ✓      │     ✓      │     ✓      │      ✓       ┃\n' +
   '┃ len()      │            │     !      │     !      │      !       ┃\n' +
   '┃ getitem()  │            │            │     !      │      !       ┃\n' +

From b678672bab91ab1aa3d928cc3db2a3db9829a901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Fri, 15 Mar 2024 05:44:21 +0100
Subject: [PATCH 010/332] Iterable Duck Types

---
 README.md  | 2 +-
 index.html | 2 +-
 parse.js   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 6b1ed97e1..b9ae92808 100644
--- a/README.md
+++ b/README.md
@@ -1309,7 +1309,7 @@ class MyAbcSequence(abc.Sequence):
 +------------+------------+------------+------------+--------------+
 |            |  Iterable  | Collection |  Sequence  | abc.Sequence |
 +------------+------------+------------+------------+--------------+
-| iter()     |    REQ*    |    REQ     |    Yes     |     Yes      |
+| iter()     |    REQ     |    REQ     |    Yes     |     Yes      |
 | contains() |    Yes     |    Yes     |    Yes     |     Yes      |
 | len()      |            |    REQ     |    REQ     |     REQ      |
 | getitem()  |            |            |    REQ     |     REQ      |
diff --git a/index.html b/index.html
index 2cbc8038b..8eff0f868 100644
--- a/index.html
+++ b/index.html
@@ -1120,7 +1120,7 @@
 

Table of required and automatically available special methods:

┏━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓
 ┃            │  Iterable  │ Collection │  Sequence  │ abc.Sequence ┃
 ┠────────────┼────────────┼────────────┼────────────┼──────────────┨
-┃ iter()     │     !*     │     !      │     ✓      │      ✓       ┃
+┃ iter()     │     !      │     !      │     ✓      │      ✓       ┃
 ┃ contains() │     ✓      │     ✓      │     ✓      │      ✓       ┃
 ┃ len()      │            │     !      │     !      │      !       ┃
 ┃ getitem()  │            │            │     !      │      !       ┃
diff --git a/parse.js b/parse.js
index cd32aa2d6..d99d15cf3 100755
--- a/parse.js
+++ b/parse.js
@@ -410,7 +410,7 @@ const DIAGRAM_6_B =
   '┏━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━━━━┓\n' +
   '┃            │  Iterable  │ Collection │  Sequence  │ abc.Sequence ┃\n' +
   '┠────────────┼────────────┼────────────┼────────────┼──────────────┨\n' +
-  '┃ iter()     │     !*     │     !      │     ✓      │      ✓       ┃\n' +
+  '┃ iter()     │     !      │     !      │     ✓      │      ✓       ┃\n' +
   '┃ contains() │     ✓      │     ✓      │     ✓      │      ✓       ┃\n' +
   '┃ len()      │            │     !      │     !      │      !       ┃\n' +
   '┃ getitem()  │            │            │     !      │      !       ┃\n' +

From a55a3159724cf1d93bbef29f95d723b950ed9e3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Sun, 17 Mar 2024 05:34:31 +0100
Subject: [PATCH 011/332] Exceptions

---
 README.md  | 3 ++-
 index.html | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index b9ae92808..ccb36b5d4 100644
--- a/README.md
+++ b/README.md
@@ -1409,9 +1409,10 @@ except (, [...]): ...
 except (, [...]) as : ...
 ```
 * **Also catches subclasses of the exception.**
-* **Use `'traceback.print_exc()'` to print the error message to stderr.**
+* **Use `'traceback.print_exc()'` to print the full error message to stderr.**
 * **Use `'print()'` to print just the cause of the exception (its arguments).**
 * **Use `'logging.exception()'` to log the passed message, followed by the full error message of the caught exception.**
+* **Use `'sys.exc_info()'` to get exception type, object and traceback of caught exception.**
 
 ### Raising Exceptions
 ```python
diff --git a/index.html b/index.html
index 8eff0f868..6ef9991e5 100644
--- a/index.html
+++ b/index.html
@@ -54,7 +54,7 @@
 
 
   
- +
@@ -1204,9 +1204,10 @@
  • Also catches subclasses of the exception.
  • -
  • Use 'traceback.print_exc()' to print the error message to stderr.
  • +
  • Use 'traceback.print_exc()' to print the full error message to stderr.
  • Use 'print(<name>)' to print just the cause of the exception (its arguments).
  • Use 'logging.exception(<message>)' to log the passed message, followed by the full error message of the caught exception.
  • +
  • Use 'sys.exc_info()' to get exception type, object and traceback of caught exception.

Raising Exceptions

raise <exception>
 raise <exception>()
@@ -2934,7 +2935,7 @@ 

Format