From 6ac047eac05a7fc825db4dc32697baaa968e5991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 9 Mar 2020 18:40:08 +0100 Subject: [PATCH 01/13] Dictionary --- README.md | 2 +- index.html | 2 +- pdf/how_to_create_pdf.md | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 40aa557..b279b43 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ value = .pop(key) # Removes item or raises KeyErro ### Counter ```python >>> from collections import Counter ->>> colors = ['blue', 'red', 'blue', 'red', 'blue'] +>>> colors = ['blue', 'blue', 'blue', 'red', 'red'] >>> counter = Counter(colors) >>> counter['yellow'] += 1 Counter({'blue': 3, 'red': 2, 'yellow': 1}) diff --git a/index.html b/index.html index ec7f732..224129b 100644 --- a/index.html +++ b/index.html @@ -279,7 +279,7 @@ value = <dict>.pop(key) for k, v in <dict>.items() if k in keys} # Returns a dictionary, filtered by keys.

Counter

>>> from collections import Counter
->>> colors = ['blue', 'red', 'blue', 'red', 'blue']
+>>> colors = ['blue', 'blue', 'blue', 'red', 'red']
 >>> counter = Counter(colors)
 >>> counter['yellow'] += 1
 Counter({'blue': 3, 'red': 2, 'yellow': 1})
diff --git a/pdf/how_to_create_pdf.md b/pdf/how_to_create_pdf.md
index 64f2d7d..c0d0be9 100644
--- a/pdf/how_to_create_pdf.md
+++ b/pdf/how_to_create_pdf.md
@@ -21,7 +21,7 @@ Printing to PDF
 * Run `./parse.js` again.
 * Open `index.html` in text editor and first remove element `


` before the `

Libraries

`. * Then replace the footer and last three `
` elements with contents of `pdf/index_for_pdf_print.html` file and save. -* Change all links in text to normal text. They can be found with this regex: `.*a href.*`. +* Change all links in text to normal text and optionally add a page number after '(p. )'. Links can be found with this regex: `.*a href.*`. * Open `index.html` in Chrome. * Change brightness of elements by right clicking on them and selecting inspect. Then click on the rectangle that represents color and toggle the color space to HSLA by clicking on the button with two vertical arrows. * Change lightness (L) percentage to: @@ -43,7 +43,7 @@ Adding headers and footers to PDF (the same for both files) * In 'Change page size' section select 'A4' for 'Page Sizes' set 'XOffset' to '0.1 in' and select page range All. * Select 'Edit PDF' tab and add headers and footers by clicking 'Header & Footer' button, selecting a preset from 'Saved Settings' dropdown menu and clicking ok. Repeat the process for each preset. * If presets get lost, the font and the margins are as follow: Borders: left-line: 0.6, left-text: 0.8, top-line: 11.4, bottom-text: 0.27, right-text-odd: 0.57, font-name: menlo, font-size: 8. -* Set title and author by selecting 'File/Propertiess...'. +* Set title and author by selecting 'File/Properties...'. * Save. Printing the PDF From 7d6274dd81096b96afa45949af720f3ee09b619f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 11 Mar 2020 11:51:23 +0100 Subject: [PATCH 02/13] Regex --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b279b43..ad91f24 100644 --- a/README.md +++ b/README.md @@ -377,7 +377,7 @@ import re ``` ### Special Sequences -* **By default digits, whitespaces and alphanumerics from all alphabets are matched, unless `'flags=re.ASCII'` argument is used.** +* **By default digits, alphanumerics and whitespaces from all alphabets are matched, unless `'flags=re.ASCII'` argument is used.** * **Use a capital letter for negation.** ```python '\d' == '[0-9]' # Matches any digit. diff --git a/index.html b/index.html index 224129b..e91b315 100644 --- a/index.html +++ b/index.html @@ -484,7 +484,7 @@ to_exclusive = <range>.stop

Special Sequences

    -
  • By default digits, whitespaces and alphanumerics from all alphabets are matched, unless 'flags=re.ASCII' argument is used.
  • +
  • By default digits, alphanumerics and whitespaces from all alphabets are matched, unless 'flags=re.ASCII' argument is used.
  • Use a capital letter for negation.
'\d' == '[0-9]'                                # Matches any digit.
 '\w' == '[a-zA-Z0-9_]'                         # Matches any alphanumeric.

From 8759cd8e134205e98a2601c86352f66202a0f4b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Wed, 11 Mar 2020 11:58:14 +0100
Subject: [PATCH 03/13] Format

---
 README.md       | 4 ++--
 index.html      | 4 ++--
 web/script_2.js | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index ad91f24..1730421 100644
--- a/README.md
+++ b/README.md
@@ -442,7 +442,7 @@ Format
 #### Comparison of presentation types:
 ```text
 +---------------+-----------------+-----------------+-----------------+-----------------+
-|               |     {}    |    {:f}   |    {:e}   |    {:%}   |
+|               |    {}    |   {:f}   |   {:e}   |   {:%}   |
 +---------------+-----------------+-----------------+-----------------+-----------------+
 |   0.000056789 |    '5.6789e-05' |     '0.000057'  |  '5.678900e-05' |     '0.005679%' |
 |   0.00056789  |    '0.00056789' |     '0.000568'  |  '5.678900e-04' |     '0.056789%' |
@@ -456,7 +456,7 @@ Format
 ```
 ```text
 +---------------+-----------------+-----------------+-----------------+-----------------+
-|               |   {:.2}  |   {:.2f}  |   {:.2e}  |   {:.2%}  |
+|               |   {:.2}  |  {:.2f}  |  {:.2e}  |  {:.2%}  |
 +---------------+-----------------+-----------------+-----------------+-----------------+
 |   0.000056789 |    '5.7e-05'    |       '0.00'    |    '5.68e-05'   |       '0.01%'   |
 |   0.00056789  |    '0.00057'    |       '0.00'    |    '5.68e-04'   |       '0.06%'   |
diff --git a/index.html b/index.html
index e91b315..eb86f4a 100644
--- a/index.html
+++ b/index.html
@@ -533,7 +533,7 @@ to_exclusive   = <range>.stop
 

Comparison of presentation types:

+---------------+-----------------+-----------------+-----------------+-----------------+
-|               |     {<real>}    |    {<real>:f}   |    {<real>:e}   |    {<real>:%}   |
+|               |    {<float>}    |   {<float>:f}   |   {<float>:e}   |   {<float>:%}   |
 +---------------+-----------------+-----------------+-----------------+-----------------+
 |   0.000056789 |    '5.6789e-05' |     '0.000057'  |  '5.678900e-05' |     '0.005679%' |
 |   0.00056789  |    '0.00056789' |     '0.000568'  |  '5.678900e-04' |     '0.056789%' |
@@ -547,7 +547,7 @@ to_exclusive   = <range>.stop
 
+---------------+-----------------+-----------------+-----------------+-----------------+
-|               |   {<float>:.2}  |   {<real>:.2f}  |   {<real>:.2e}  |   {<real>:.2%}  |
+|               |   {<float>:.2}  |  {<float>:.2f}  |  {<float>:.2e}  |  {<float>:.2%}  |
 +---------------+-----------------+-----------------+-----------------+-----------------+
 |   0.000056789 |    '5.7e-05'    |       '0.00'    |    '5.68e-05'   |       '0.01%'   |
 |   0.00056789  |    '0.00057'    |       '0.00'    |    '5.68e-04'   |       '0.06%'   |
diff --git a/web/script_2.js b/web/script_2.js
index 2a41d3f..3ffc203 100644
--- a/web/script_2.js
+++ b/web/script_2.js
@@ -105,12 +105,12 @@ const DIAGRAM_4_B =
  
 const DIAGRAM_5_A = 
   "+---------------+-----------------+-----------------+-----------------+-----------------+\n" +
-  "|               |     {}    |    {:f}   |    {:e}   |    {:%}   |\n" +
+  "|               |    {}    |   {:f}   |   {:e}   |   {:%}   |\n" +
   "+---------------+-----------------+-----------------+-----------------+-----------------+\n";
 
 const DIAGRAM_5_B =
   "┏━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
-  "┃               │     {<real>}    │    {<real>:f}   │    {<real>:e}   │    {<real>:%}   ┃\n" +
+  "┃               │    {<float>}    │   {<float>:f}   │   {<float>:e}   │   {<float>:%}   ┃\n" +
   "┠───────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┨\n" +
   "┃   0.000056789 │    '5.6789e-05' │     '0.000057'  │  '5.678900e-05' │     '0.005679%' ┃\n" +
   "┃   0.00056789  │    '0.00056789' │     '0.000568'  │  '5.678900e-04' │     '0.056789%' ┃\n" +
@@ -124,12 +124,12 @@ const DIAGRAM_5_B =
 
 const DIAGRAM_6_A =
   "+---------------+-----------------+-----------------+-----------------+-----------------+\n" +
-  "|               |   {:.2}  |   {:.2f}  |   {:.2e}  |   {:.2%}  |\n" +
+  "|               |   {:.2}  |  {:.2f}  |  {:.2e}  |  {:.2%}  |\n" +
   "+---------------+-----------------+-----------------+-----------------+-----------------+\n";
 
 const DIAGRAM_6_B =
   "┏━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━┓\n" +
-  "┃               │   {<float>:.2}  │   {<real>:.2f}  │   {<real>:.2e}  │   {<real>:.2%}  ┃\n" +
+  "┃               │   {<float>:.2}  │  {<float>:.2f}  │  {<float>:.2e}  │  {<float>:.2%}  ┃\n" +
   "┠───────────────┼─────────────────┼─────────────────┼─────────────────┼─────────────────┨\n" +
   "┃   0.000056789 │    '5.7e-05'    │       '0.00'    │    '5.68e-05'   │       '0.01%'   ┃\n" +
   "┃   0.00056789  │    '0.00057'    │       '0.00'    │    '5.68e-04'   │       '0.06%'   ┃\n" +

From 14eff553c023782acdb7272014f73018e71493dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Wed, 11 Mar 2020 12:00:00 +0100
Subject: [PATCH 04/13] Combinatorics

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

diff --git a/README.md b/README.md
index 1730421..ea2e439 100644
--- a/README.md
+++ b/README.md
@@ -541,7 +541,7 @@ shuffle()
 Combinatorics
 -------------
 * **Every function returns an iterator.**
-* **If you want to print the iterator, you need to pass it to the list() function!**
+* **If you want to print the iterator, you need to pass it to the list() function first!**
 
 ```python
 from itertools import product, combinations, combinations_with_replacement, permutations
diff --git a/index.html b/index.html
index eb86f4a..1d59dce 100644
--- a/index.html
+++ b/index.html
@@ -613,7 +613,7 @@ shuffle(<list>)
 
 

#Combinatorics

  • Every function returns an iterator.
  • -
  • If you want to print the iterator, you need to pass it to the list() function!
  • +
  • If you want to print the iterator, you need to pass it to the list() function first!
from itertools import product, combinations, combinations_with_replacement, permutations
 
From 54db446de455ebf2b2cc2154a9adf79c9c9b4dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 11 Mar 2020 12:02:11 +0100 Subject: [PATCH 05/13] Duck types --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ea2e439..d28b3b8 100644 --- a/README.md +++ b/README.md @@ -1093,7 +1093,7 @@ class MyComparable: ```python class MyHashable: def __init__(self, a): - self._a = copy.deepcopy(a) + self._a = a @property def a(self): return self._a diff --git a/index.html b/index.html index 1d59dce..2c1019f 100644 --- a/index.html +++ b/index.html @@ -1041,7 +1041,7 @@ Z = dataclasses.make_dataclass('Z', [That is why Python automatically makes classes unhashable if you only implement eq().
class MyHashable:
     def __init__(self, a):
-        self._a = copy.deepcopy(a)
+        self._a = a
     @property
     def a(self):
         return self._a

From 553f8dd4c7fa70cca6b0526d7a0c9b8aada5d7b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Wed, 11 Mar 2020 12:06:03 +0100
Subject: [PATCH 06/13] Duck types

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

diff --git a/README.md b/README.md
index d28b3b8..07e7822 100644
--- a/README.md
+++ b/README.md
@@ -1146,7 +1146,7 @@ class Counter:
 ```
 
 #### Python has many different iterator objects:
-* **Objects returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
+* **Iterators returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
 * **Objects returned by the [itertools](#itertools) module, such as count, repeat and cycle.**
 * **Generators returned by the [generator functions](#generator) and [generator expressions](#comprehension).**
 * **File objects returned by the [open()](#open) function, etc.**
@@ -1170,7 +1170,7 @@ class Counter:
 ```
 
 ### Context Manager
-* **Enter() should lock the resources and (optionally) return an object.**
+* **Enter() should lock the resources and optionally return an object.**
 * **Exit() should release the resources.**
 * **Any exception that happens inside the with block is passed to the exit() method.**
 * **If it wishes to suppress the exception it must return a true value.** 
diff --git a/index.html b/index.html
index 2c1019f..e452d20 100644
--- a/index.html
+++ b/index.html
@@ -1093,7 +1093,7 @@ Z = dataclasses.make_dataclass('Z', [1, 2, 3)
 

Python has many different iterator objects:

    -
  • Objects returned by the iter() function, such as list_iterator and set_iterator.
  • +
  • Iterators returned by the iter() function, such as list_iterator and set_iterator.
  • Objects returned by the itertools module, such as count, repeat and cycle.
  • Generators returned by the generator functions and generator expressions.
  • File objects returned by the open() function, etc.
  • @@ -1116,7 +1116,7 @@ Z = dataclasses.make_dataclass('Z', [1, 2, 3)

Context Manager

    -
  • Enter() should lock the resources and (optionally) return an object.
  • +
  • Enter() should lock the resources and optionally return an object.
  • Exit() should release the resources.
  • Any exception that happens inside the with block is passed to the exit() method.
  • If it wishes to suppress the exception it must return a true value.
  • From 0c8bdc682ac6b54c7098d5b456c513fbdb22a027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 11 Mar 2020 12:14:04 +0100 Subject: [PATCH 07/13] Iterable duck types --- README.md | 5 +++-- index.html | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07e7822..085d8d6 100644 --- a/README.md +++ b/README.md @@ -1205,8 +1205,9 @@ class MyIterable: def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) + def __contains__(self, el): + return el in self.a ``` ```python diff --git a/index.html b/index.html index e452d20..09e8692 100644 --- a/index.html +++ b/index.html @@ -1144,8 +1144,9 @@ Hello World! def __init__(self, a): self.a = a def __iter__(self): - for el in self.a: - yield el + return iter(self.a) + def __contains__(self, el): + return el in self.a
From 026a976f5adb91541c00e72abd9814fc47f67b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 11 Mar 2020 12:40:03 +0100 Subject: [PATCH 08/13] Exceptions --- README.md | 4 ++-- index.html | 4 ++-- web/script_2.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 085d8d6..636f6ef 100644 --- a/README.md +++ b/README.md @@ -1337,7 +1337,7 @@ from functools import partial LogicOp = Enum('LogicOp', {'AND': partial(lambda l, r: l and r), 'OR' : partial(lambda l, r: l or r)}) ``` -* **Another solution in this particular case is to use built-in functions `'and_'` and `'or_'` from the module [operator](#operator).** +* **Another solution in this particular case is to use built-in functions and\_() and or\_() from the module [operator](#operator).** Exceptions @@ -1420,7 +1420,7 @@ BaseException +-- StopIteration # Raised by next() when run on an empty iterator. +-- 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. + +-- UnicodeError # Raised when encoding/decoding strings to/from bytes fails. ``` #### Collections and their exceptions: diff --git a/index.html b/index.html index 09e8692..d4e4b11 100644 --- a/index.html +++ b/index.html @@ -1266,7 +1266,7 @@ LogicOp = Enum('LogicOp', {'and_' and 'or_' from the module operator. +
  • Another solution in this particular case is to use built-in functions and_() and or_() from the module operator.
  • #Exceptions

    Basic Example

    try:
         <code>
    @@ -1334,7 +1334,7 @@ error_msg = traceback.format_exception(exc_type, <name>, <name>.__tr
           +-- StopIteration           # Raised by next() when run on an empty iterator.
           +-- 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.
    +           +-- UnicodeError       # Raised when encoding/decoding strings to/from bytes fails.
     

    Collections and their exceptions:

    +-----------+------------+------------+------------+
    diff --git a/web/script_2.js b/web/script_2.js
    index 3ffc203..00aeabd 100644
    --- a/web/script_2.js
    +++ b/web/script_2.js
    @@ -183,7 +183,7 @@ const DIAGRAM_8_B =
       "      ├── StopIteration           # Raised by next() when run on an empty iterator.\n" +
       "      ├── TypeError               # Raised when an argument is of wrong type.\n" +
       "      └── ValueError              # When an argument is of right type but inappropriate value.\n" +
    -  "           └── UnicodeError       # Raised when encoding/decoding strings from/to bytes fails.\n";
    +  "           └── UnicodeError       # Raised when encoding/decoding strings to/from bytes fails.\n";
     
     const DIAGRAM_9_A =
       '+------------------+--------------+--------------+--------------+\n' +
    
    From a65c3d978e3c5a2207d7c9f2b4f81a0727d55590 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Jure=20=C5=A0orn?= 
    Date: Wed, 11 Mar 2020 15:45:14 +0100
    Subject: [PATCH 09/13] OS commands
    
    ---
     README.md  | 6 +++---
     index.html | 6 +++---
     2 files changed, 6 insertions(+), 6 deletions(-)
    
    diff --git a/README.md b/README.md
    index 636f6ef..261c56b 100644
    --- a/README.md
    +++ b/README.md
    @@ -1590,7 +1590,7 @@ from glob import glob
     ```
     
     ```python
    -  = getcwd()                   # Returns current working directory.
    +  = getcwd()                   # Returns the current working directory.
       = path.join(, ...)     # Joins two or more pathname components.
       = path.abspath()       # Returns absolute path.
     ```
    @@ -1664,7 +1664,7 @@ from pathlib import Path
     OS Commands
     -----------
     ### Files and Directories
    -* **Paths can be either strings, Paths, or DirEntry objects.**
    +* **Paths can be either strings, Paths or DirEntry objects.**
     * **Functions report OS related errors by raising either OSError or one of its [subclasses](#exceptions-1).**
     
     ```python
    @@ -1672,7 +1672,7 @@ import os, shutil
     ```
     
     ```python
    -os.chdir()                    # Changes current working directory.
    +os.chdir()                    # Changes the current working directory.
     os.mkdir(, mode=0o777)        # Creates a directory. Mode is in octal.
     ```
     
    diff --git a/index.html b/index.html
    index d4e4b11..dde30d8 100644
    --- a/index.html
    +++ b/index.html
    @@ -1470,7 +1470,7 @@ value = args.<name>
     from glob import glob
     
    -
    <str>  = getcwd()                   # Returns current working directory.
    +
    <str>  = getcwd()                   # Returns the current working directory.
     <str>  = path.join(<path>, ...)     # Joins two or more pathname components.
     <str>  = path.abspath(<path>)       # Returns absolute path.
     
    @@ -1517,14 +1517,14 @@ value = args.<name> <file> = open(<Path>) # Opens the file and returns file object.

    #OS Commands

    Files and Directories

      -
    • Paths can be either strings, Paths, or DirEntry objects.
    • +
    • Paths can be either strings, Paths or DirEntry objects.
    • Functions report OS related errors by raising either OSError or one of its subclasses.
    import os, shutil
     
    -
    os.chdir(<path>)                    # Changes current working directory.
    +
    os.chdir(<path>)                    # Changes the current working directory.
     os.mkdir(<path>, mode=0o777)        # Creates a directory. Mode is in octal.
     
    shutil.copy(from, to)               # Copies the file. 'to' can be a directory.
    
    From 66b5d5cdb2c40ad3d339def9e3f1f0a8983d0af3 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Jure=20=C5=A0orn?= 
    Date: Wed, 11 Mar 2020 17:31:40 +0100
    Subject: [PATCH 10/13] CSV
    
    ---
     README.md  | 2 +-
     index.html | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/README.md b/README.md
    index 261c56b..506c948 100644
    --- a/README.md
    +++ b/README.md
    @@ -1788,7 +1788,7 @@ import csv
     .writerow()     # Encodes objects using `str()`.
     .writerows()  # Appends multiple rows.
     ```
    -* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' linendings!**
    +* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!**
     
     ### Parameters
     * **`'dialect'` - Master parameter that sets the default values.**
    diff --git a/index.html b/index.html
    index dde30d8..2737d6c 100644
    --- a/index.html
    +++ b/index.html
    @@ -1604,7 +1604,7 @@ CompletedProcess(args=['bc', 'newline=""' argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' linendings!
    +
  • File must be opened with 'newline=""' argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!
  • Parameters

    • 'dialect' - Master parameter that sets the default values.
    • From 916635fd873908e1edc2c1fcfe4effd10152c228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 12 Mar 2020 04:07:36 +0100 Subject: [PATCH 11/13] SQLite --- README.md | 6 +++--- index.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 506c948..2e07c09 100644 --- a/README.md +++ b/README.md @@ -1847,9 +1847,9 @@ db.close() ### Read **Returned values can be of type str, int, float, bytes or None.** ```python - = db.execute('') # Can raise sqlite3.OperationalError. + = db.execute('') # Raises a subclass of sqlite3.Error. = .fetchone() # Returns next row. Also next(). - = .fetchall() # Returns remaining rows. + = .fetchall() # Returns remaining rows. Also list(). ``` ### Write @@ -1890,7 +1890,7 @@ db.executemany('', ) # Runs execute() many times. from mysql import connector db = connector.connect(host=, user=, password=, database=) = db.cursor() -.execute('') # Only cursor has execute method. +.execute('') # Raises a subclass of mysql.connector.Error. .execute('', ) # Replaces '%s's in query with values. .execute('', ) # Replaces '%()s's with values. ``` diff --git a/index.html b/index.html index 2737d6c..e9aa5a7 100644 --- a/index.html +++ b/index.html @@ -1650,9 +1650,9 @@ db.close() -

      Read

      Returned values can be of type str, int, float, bytes or None.

      <cursor> = db.execute('<query>')                # Can raise sqlite3.OperationalError.
      +

      Read

      Returned values can be of type str, int, float, bytes or None.

      <cursor> = db.execute('<query>')                # Raises a subclass of sqlite3.Error.
       <tuple>  = <cursor>.fetchone()                  # Returns next row. Also next(<cursor>).
      -<list>   = <cursor>.fetchall()                  # Returns remaining rows.
      +<list>   = <cursor>.fetchall()                  # Returns remaining rows. Also list(<cursor>).
       
      @@ -1685,7 +1685,7 @@ db.executemany('<query>', <coll_of_abo from mysql import connector db = connector.connect(host=<str>, user=<str>, password=<str>, database=<str>) <cursor> = db.cursor() -<cursor>.execute('<query>') # Only cursor has execute method. +<cursor>.execute('<query>') # Raises a subclass of mysql.connector.Error. <cursor>.execute('<query>', <list/tuple>) # Replaces '%s's in query with values. <cursor>.execute('<query>', <dict/namedtuple>) # Replaces '%(<key>)s's with values.
      From e96c177c9e4aa92e6ce200af07dd3be1a355c91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 12 Mar 2020 04:22:16 +0100 Subject: [PATCH 12/13] Struct --- README.md | 2 +- index.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2e07c09..5267761 100644 --- a/README.md +++ b/README.md @@ -1959,7 +1959,7 @@ b'\x00\x01\x00\x02\x00\x00\x00\x03' ``` ### Format -#### For standard sizes start format string with: +#### For standard type sizes start format string with: * **`'='` - native byte order** * **`'<'` - little-endian** * **`'>'` - big-endian (also `'!'`)** diff --git a/index.html b/index.html index e9aa5a7..7e5d926 100644 --- a/index.html +++ b/index.html @@ -1736,11 +1736,11 @@ db = connector.connect(host=<str>, user=<str>, password=<str>, (1, 2, 3)
    -

    Format

    For standard sizes start format string with:

      +

      Format

      For standard type sizes start format string with:

      • '=' - native byte order
      • '<' - little-endian
      • '>' - big-endian (also '!')
      • -

      Integer types. Use a capital letter for unsigned type. Standard sizes are in brackets:

        +

      Integer types. Use a capital letter for unsigned type. Standard sizes are in brackets:

      • 'x' - pad byte
      • 'b' - char (1)
      • 'h' - short (2)
      • From eb0b978055402ff5cfa87ae99ab478090bbeee11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 12 Mar 2020 04:29:45 +0100 Subject: [PATCH 13/13] Array --- README.md | 3 ++- index.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5267761..91436d5 100644 --- a/README.md +++ b/README.md @@ -1983,8 +1983,9 @@ Array ```python from array import array - = array('', ) # Array from coll. of numbers. + = array('', ) # Array from collection of numbers. = array('', ) # Array from bytes object. + = array('', ) # Treats array as a sequence of numbers. = bytes() # Or: .tobytes() ``` diff --git a/index.html b/index.html index 7e5d926..496a19c 100644 --- a/index.html +++ b/index.html @@ -1758,8 +1758,9 @@ db = connector.connect(host=<str>, user=<str>, password=<str>,

        #Array

        List that can only hold numbers of a predefined type. Available types and their sizes in bytes are listed above.

        from array import array
        -<array> = array('<typecode>', <collection>)    # Array from coll. of numbers.
        +<array> = array('<typecode>', <collection>)    # Array from collection of numbers.
         <array> = array('<typecode>', <bytes>)         # Array from bytes object.
        +<array> = array('<typecode>', <array>)         # Treats array as a sequence of numbers.
         <bytes> = bytes(<array>)                       # Or: <array>.tobytes()