From 1b04c2c8d26acfbd1893f7477278003d3b4cfecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 6 Jan 2022 15:59:43 +0100 Subject: [PATCH] Class, Tabulate --- README.md | 30 +++++++++++++++--------------- index.html | 34 +++++++++++++++++----------------- pdf/README.md | 4 ++++ pdf/remove_links.py | 3 +-- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index dd9bdc0..265584b 100644 --- a/README.md +++ b/README.md @@ -708,27 +708,27 @@ def add(*a): #### Legal argument combinations: ```python -def f(*, x, y, z): # f(x=1, y=2, z=3) -def f(x, *, y, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) -def f(x, y, *, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) +def f(*, x, y, z): # f(x=1, y=2, z=3) +def f(x, *, y, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) +def f(x, y, *, z): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) ``` ```python -def f(*args): # f(1, 2, 3) -def f(x, *args): # f(1, 2, 3) -def f(*args, z): # f(1, 2, z=3) +def f(*args): # f(1, 2, 3) +def f(x, *args): # f(1, 2, 3) +def f(*args, z): # f(1, 2, z=3) ``` ```python -def f(**kwargs): # f(x=1, y=2, z=3) -def f(x, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) -def f(*, x, **kwargs): # f(x=1, y=2, z=3) +def f(**kwargs): # f(x=1, y=2, z=3) +def f(x, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) +def f(*, x, **kwargs): # f(x=1, y=2, z=3) ``` ```python -def f(*args, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3) -def f(x, *args, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3) -def f(*args, y, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) +def f(*args, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3) +def f(x, *args, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3) +def f(*args, y, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) ``` ### Other Uses @@ -1042,8 +1042,8 @@ class : : = : list/dict/set = field(default_factory=list/dict/set) ``` -* **Objects can be made [sortable](#sortable) with `'order=True'` and immutable with `'frozen=True'`.** -* **For object to be [hashable](#hashable), all attributes must be hashable and frozen must be True.** +* **Objects can be made sortable with `'order=True'` and immutable with `'frozen=True'`.** +* **For object to be hashable, all attributes must be [hashable](#hashable) and frozen must be True.** * **Function field() is needed because `': list = []'` would make a list that is shared among all instances. Its 'default_factory' argument can be any [callable](#callable).** * **For attributes of arbitrary type use `'typing.Any'`.** @@ -2393,7 +2393,7 @@ with open('test.csv', encoding='utf-8', newline='') as file: rows = csv.reader(file) header = [a.title() for a in next(rows)] table = tabulate.tabulate(rows, header) - print(table) +print(table) ``` diff --git a/index.html b/index.html index d81b1f2..b719efc 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -619,22 +619,22 @@ func(*args, **kwargs)
>>> add(1, 2, 3)
 6
 
-

Legal argument combinations:

def f(*, x, y, z):             # f(x=1, y=2, z=3)
-def f(x, *, y, z):             # f(x=1, y=2, z=3) | f(1, y=2, z=3)
-def f(x, y, *, z):             # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)
+

Legal argument combinations:

def f(*, x, y, z):          # f(x=1, y=2, z=3)
+def f(x, *, y, z):          # f(x=1, y=2, z=3) | f(1, y=2, z=3)
+def f(x, y, *, z):          # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3)
 
-
def f(*args):                  # f(1, 2, 3)
-def f(x, *args):               # f(1, 2, 3)
-def f(*args, z):               # f(1, 2, z=3)
+
def f(*args):               # f(1, 2, 3)
+def f(x, *args):            # f(1, 2, 3)
+def f(*args, z):            # f(1, 2, z=3)
 
-
def f(**kwargs):               # f(x=1, y=2, z=3)
-def f(x, **kwargs):            # f(x=1, y=2, z=3) | f(1, y=2, z=3)
-def f(*, x, **kwargs):         # f(x=1, y=2, z=3)
+
def f(**kwargs):            # f(x=1, y=2, z=3)
+def f(x, **kwargs):         # f(x=1, y=2, z=3) | f(1, y=2, z=3)
+def f(*, x, **kwargs):      # f(x=1, y=2, z=3)
 
-
def f(*args, **kwargs):        # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)
-def f(x, *args, **kwargs):     # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)
-def f(*args, y, **kwargs):     # f(x=1, y=2, z=3) | f(1, y=2, z=3)
+
def f(*args, **kwargs):     # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)
+def f(x, *args, **kwargs):  # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3) | f(1, 2, 3)
+def f(*args, y, **kwargs):  # f(x=1, y=2, z=3) | f(1, y=2, z=3)
 

Other Uses

<list>  = [*<collection> [, ...]]
 <set>   = {*<collection> [, ...]}
@@ -885,8 +885,8 @@ Z = dataclasses.make_dataclass('Z', [
-
  • 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.
  • +
  • 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.
  • 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.
  • For attributes of arbitrary type use 'typing.Any'.
  • @@ -1956,7 +1956,7 @@ plt.clf() # Clea rows = csv.reader(file) header = [a.title() for a in next(rows)] table = tabulate.tabulate(rows, header) - print(table) +print(table)
    @@ -2881,7 +2881,7 @@ $ pyinstaller script.py --add-data '<path>:.' diff --git a/pdf/README.md b/pdf/README.md index b299c81..82f00bf 100644 --- a/pdf/README.md +++ b/pdf/README.md @@ -2,6 +2,7 @@ How To Create PDF (on macOS) ============================ PDF file can also be purchased here: https://transactions.sendowl.com/products/78175486/4422834F/view + Setup ----- * Install Adobe Acrobat Pro DC. @@ -9,6 +10,7 @@ Setup * Change date in header and footer element of `web/template.html`. * Run `./parse.js` and commit changes. + Printing to PDF --------------- ### Normal PDF @@ -39,6 +41,7 @@ Printing to PDF * Select 'Print...' with destination 'Save as PDF', paper size 'A4', 'Default' margins (top 10mm, right 9.5mm, bottom 8mm and left 10mm), 'Default' scale and no headers and footers and save (the document should be 51 pages long with last page empty). * Check if plots were rendered correctly. + Adding headers and footers to PDF (the same for both files) ----------------------------------------------------------- * Open the PDF file in Adobe Acrobat Pro DC. @@ -52,6 +55,7 @@ Adding headers and footers to PDF (the same for both files) * Save the progress by running 'Save as' in Format: 'Adobe PDF Files'. * Run 'Save as' again, this time in 'Adobe PDF Files, Optimized', so that Menlo font error gets fixed. + Printing the PDF ---------------- * Open the PDF that was optimized for printing in Chrome and print on A4 on both sides with default margins, scale 98% and no headers and footers. diff --git a/pdf/remove_links.py b/pdf/remove_links.py index 1a98ae5..e46c0b8 100755 --- a/pdf/remove_links.py +++ b/pdf/remove_links.py @@ -11,8 +11,7 @@ MATCHES = { '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\' before the colon converts object to string by calling its repr() method.': 'Adding \'!r\' before the colon converts object to string by calling its repr() method (p. 14).', 'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable (p. 17), but is usually implemented as a function that returns a closure (p. 12).', - '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.', + '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 (p. 16) 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).', 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator.': 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator (p. 3).', 'Objects returned by the itertools module, such as count, repeat and cycle.': 'Objects returned by the itertools module, such as count, repeat and cycle (p. 3).',