From 03426b838fc5a999bc41e18d80e556b60ed08465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 7 Oct 2024 14:53:07 +0200 Subject: [PATCH] Decorator, SQLite --- README.md | 22 +++++++++++----------- index.html | 26 +++++++++++++------------- parse.js | 24 ++++++++++++------------ 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index a3d29a2..d2a3433 100644 --- a/README.md +++ b/README.md @@ -925,7 +925,7 @@ from functools import cache def fib(n): return n if n < 2 else fib(n-2) + fib(n-1) ``` -* **Potential problem with cache is that it can grow indefinitely. To clear the cache run `'fib.cache_clear()'` or use `'@functools.lru_cache(maxsize=)'` instead.** +* **Potential problem with cache is that it can grow indefinitely. To clear its stored values run `'fib.cache_clear()'`, or use `'@lru_cache(maxsize=)'` decorator instead.** * **CPython interpreter limits recursion depth to 3000 by default. To increase it run `'sys.setrecursionlimit()'`.** ### Parametrized Decorator @@ -1937,14 +1937,14 @@ with .begin(): ... # Exits the block with commit or ``` ```text -+------------+--------------+----------+----------------------------------+ -| Dialect | pip3 install | import | Dependencies | -+------------+--------------+----------+----------------------------------+ -| mysql | mysqlclient | MySQLdb | www.pypi.org/project/mysqlclient | -| postgresql | psycopg2 | psycopg2 | www.pypi.org/project/psycopg2 | -| mssql | pyodbc | pyodbc | www.pypi.org/project/pyodbc | -| oracle | oracledb | oracledb | www.pypi.org/project/oracledb | -+------------+--------------+----------+----------------------------------+ ++-----------------+--------------+----------------------------------+ +| Dialect | pip3 install | Dependencies | ++-----------------+--------------+----------------------------------+ +| mysql | mysqlclient | www.pypi.org/project/mysqlclient | +| postgresql | psycopg2 | www.pypi.org/project/psycopg2 | +| mssql | pyodbc | www.pypi.org/project/pyodbc | +| oracle+oracledb | oracledb | www.pypi.org/project/oracledb | ++-----------------+--------------+----------------------------------+ ``` @@ -2525,7 +2525,7 @@ from selenium import webdriver .click/clear() # Also .send_keys(). ``` -#### XPath — also available in lxml, Scrapy, and browser's console via `'$x()'`: +#### XPath — also available in lxml, Scrapy, and browser's console via `'$x("")'`: ```python = //[/ or // ] # /, //, /../ = ///following:: # Next element. Also preceding/parent/… @@ -2567,7 +2567,7 @@ def serve_html(sport): return flask.render_template_string('

{{title}}

', title=sport) ``` * **Use `'render_template(filename, )'` to render file located in templates dir.** -* **To return an error code use `'abort()'` and to redirect use `'redirect("")'`.** +* **To return an error code use `'abort()'` and to redirect use `'redirect()'`.** * **`'request.args[]'` returns parameter from the query string (URL part after '?').** * **`'session[] = '` stores session data. Needs `'app.secret_key = '`.** diff --git a/index.html b/index.html index ffb1c46..568616c 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -776,7 +776,7 @@ player = Player(point, direction) #
    -
  • Potential problem with cache is that it can grow indefinitely. To clear the cache run 'fib.cache_clear()' or use '@functools.lru_cache(maxsize=<int>)' instead.
  • +
  • Potential problem with cache is that it can grow indefinitely. To clear its stored values run 'fib.cache_clear()', or use '@lru_cache(maxsize=<int>)' decorator instead.
  • CPython interpreter limits recursion depth to 3000 by default. To increase it run 'sys.setrecursionlimit(<int>)'.

Parametrized Decorator

A decorator that accepts arguments and returns a normal decorator that accepts a function.

from functools import wraps
@@ -1605,14 +1605,14 @@ CompletedProcess(args=['bc', ┏━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
-┃ Dialect    │ pip3 install │ import   │           Dependencies           ┃
-┠────────────┼──────────────┼──────────┼──────────────────────────────────┨
-┃ mysql      │ mysqlclient  │ MySQLdb  │ www.pypi.org/project/mysqlclient ┃
-┃ postgresql │ psycopg2     │ psycopg2 │ www.pypi.org/project/psycopg2    ┃
-┃ mssql      │ pyodbc       │ pyodbc   │ www.pypi.org/project/pyodbc      ┃
-┃ oracle     │ oracledb     │ oracledb │ www.pypi.org/project/oracledb    ┃
-┗━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
+
┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+┃ Dialect         │ pip3 install │           Dependencies           ┃
+┠─────────────────┼──────────────┼──────────────────────────────────┨
+┃ mysql           │ mysqlclient  │ www.pypi.org/project/mysqlclient ┃
+┃ postgresql      │ psycopg2     │ www.pypi.org/project/psycopg2    ┃
+┃ mssql           │ pyodbc       │ www.pypi.org/project/pyodbc      ┃
+┃ oracle+oracledb │ oracledb     │ www.pypi.org/project/oracledb    ┃
+┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
 

#Bytes

A bytes object is an immutable sequence of single bytes. Mutable version is called bytearray.

<bytes> = b'<str>'                       # Only accepts ASCII characters and \x00-\xff.
 <int>   = <bytes>[index]                 # Returns an int in range from 0 to 255.
@@ -2072,7 +2072,7 @@ print(f'{python_url},
 
-

XPath — also available in lxml, Scrapy, and browser's console via '$x(<xpath>)':

<xpath>     = //<element>[/ or // <element>]           # /<child>, //<descendant>, /../<siblng>
+

XPath — also available in lxml, Scrapy, and browser's console via '$x("<xpath>")':

<xpath>     = //<element>[/ or // <element>]           # /<child>, //<descendant>, /../<siblng>
 <xpath>     = //<element>/following::<element>         # Next element. Also preceding/parent/…
 <element>   = <tag><conditions><index>                 # `<tag> = */a/…`, `<index> = [1/2/…]`.
 <condition> = [<sub_cond> [and/or <sub_cond>]]         # For negation use `not(<sub_cond>)`.
@@ -2106,7 +2106,7 @@ app.run(host=None, port='render_template(filename, <kwargs>)' to render file located in templates dir.
-
  • To return an error code use 'abort(<int>)' and to redirect use 'redirect("<url>")'.
  • +
  • To return an error code use 'abort(<int>)' and to redirect use 'redirect(<url>)'.
  • 'request.args[<str>]' returns parameter from the query string (URL part after '?').
  • 'session[<str>] = <obj>' stores session data. Needs 'app.secret_key = <str>'.
  • @@ -2928,7 +2928,7 @@ $ deactivate # Deactivates the active diff --git a/parse.js b/parse.js index f3e68f3..d1bd4c8 100755 --- a/parse.js +++ b/parse.js @@ -500,19 +500,19 @@ const DIAGRAM_9_B = "┗━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┛\n"; const DIAGRAM_95_A = - '+------------+--------------+----------+----------------------------------+\n' + - '| Dialect | pip3 install | import | Dependencies |\n' + - '+------------+--------------+----------+----------------------------------+\n'; + '+-----------------+--------------+----------------------------------+\n' + + '| Dialect | pip3 install | Dependencies |\n' + + '+-----------------+--------------+----------------------------------+\n'; const DIAGRAM_95_B = - '┏━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n' + - '┃ Dialect │ pip3 install │ import │ Dependencies ┃\n' + - '┠────────────┼──────────────┼──────────┼──────────────────────────────────┨\n' + - '┃ mysql │ mysqlclient │ MySQLdb │ www.pypi.org/project/mysqlclient ┃\n' + - '┃ postgresql │ psycopg2 │ psycopg2 │ www.pypi.org/project/psycopg2 ┃\n' + - '┃ mssql │ pyodbc │ pyodbc │ www.pypi.org/project/pyodbc ┃\n' + - '┃ oracle │ oracledb │ oracledb │ www.pypi.org/project/oracledb ┃\n' + - '┗━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n'; + '┏━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n' + + '┃ Dialect │ pip3 install │ Dependencies ┃\n' + + '┠─────────────────┼──────────────┼──────────────────────────────────┨\n' + + '┃ mysql │ mysqlclient │ www.pypi.org/project/mysqlclient ┃\n' + + '┃ postgresql │ psycopg2 │ www.pypi.org/project/psycopg2 ┃\n' + + '┃ mssql │ pyodbc │ www.pypi.org/project/pyodbc ┃\n' + + '┃ oracle+oracledb │ oracledb │ www.pypi.org/project/oracledb ┃\n' + + '┗━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n'; const DIAGRAM_10_A = '+-------------+-------------+\n' + @@ -838,7 +838,7 @@ function fixClasses() { function fixHighlights() { $(`code:contains( = ±0b)`).html(BIN_HEX); - $(`code:contains(@cache)`).html(CACHE); + $(`code:contains( + fib(n)`).html(CACHE); $(`code:contains(@debug(print_result=True))`).html(PARAMETRIZED_DECORATOR); $(`code:contains(print/str/repr([]))`).html(REPR_USE_CASES); $(`code:contains((self, a=None):)`).html(CONSTRUCTOR_OVERLOADING);