From fb82911313dd297d70d2482805c59e7e3b099ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 30 Jul 2025 17:36:47 +0200 Subject: [PATCH] Regex, Class, Coroutines --- README.md | 8 ++++---- index.html | 8 ++++---- parse.js | 2 +- pdf/remove_links.py | 1 + 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 79c8ead..4d774ec 100644 --- a/README.md +++ b/README.md @@ -370,7 +370,7 @@ import re * **Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals (since 3.12).** * **Argument 'new' of re.sub() can be a function that accepts Match object and returns a str.** -* **Argument `'flags=re.IGNORECASE'` can be used with all listed regex functions.** +* **Argument `'flags=re.IGNORECASE'` can be used with all functions that are listed above.** * **Argument `'flags=re.MULTILINE'` makes `'^'` and `'$'` match the start/end of each line.** * **Argument `'flags=re.DOTALL'` makes `'.'` also accept the `'\n'` (besides all other chars).** * **`'re.compile()'` returns a Pattern object with methods sub(), findall(), etc.** @@ -971,7 +971,7 @@ class MyClass: >>> obj.a, str(obj), repr(obj) (1, '1', 'MyClass(1)') ``` -* **Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand,
for example, `'print(a)'` calls `'a.__str__()'` and `'a + b'` calls `'a.__add__(b)'`.** +* **Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand, for example, `'print(a)'` calls `'a.__str__()'` and `'a + b'` calls `'a.__add__(b)'`.** * **Methods decorated with `'@staticmethod'` receive neither 'self' nor 'cls' argument.** * **Return value of str() special method should be readable and of repr() unambiguous. If only repr() is defined, it will also be used for str().** @@ -1042,7 +1042,7 @@ class : ``` * **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.** -* **Function field() is needed because `': list = []'` would make a list that is shared among all instances. Its 'default_factory' argument accepts any callable object.** +* **Function field() is needed because `': list = []'` would make a list that is shared among all instances. Its 'default_factory' argument accepts any [callable](#callable) object.** * **For attributes of arbitrary type use `'typing.Any'`.** ```python @@ -2336,7 +2336,7 @@ D = enum.Enum('D', 'n e s w') # Direction (north, east, etc.). W, H = 15, 7 # Width and height constants. def main(screen): - curses.curs_set(0) # Makes cursor invisible. + curses.curs_set(0) # Makes the cursor invisible. screen.nodelay(True) # Makes getch() non-blocking. asyncio.run(main_coroutine(screen)) # Starts running asyncio code. diff --git a/index.html b/index.html index fbb3516..b1270ec 100644 --- a/index.html +++ b/index.html @@ -351,7 +351,7 @@ Point(x=1, y=2
  • Raw string literals do not interpret escape sequences, thus enabling us to use regex-specific escape sequences that cause SyntaxWarning in normal string literals (since 3.12).
  • Argument 'new' of re.sub() can be a function that accepts Match object and returns a str.
  • -
  • Argument 'flags=re.IGNORECASE' can be used with all listed regex functions.
  • +
  • Argument 'flags=re.IGNORECASE' can be used with all functions that are listed above.
  • Argument 'flags=re.MULTILINE' makes '^' and '$' match the start/end of each line.
  • Argument 'flags=re.DOTALL' makes '.' also accept the '\n' (besides all other chars).
  • 're.compile(<regex>)' returns a Pattern object with methods sub(), findall(), etc.
  • @@ -827,7 +827,7 @@ player = Player(point, direction) # (1, '1', 'MyClass(1)')
      -
    • Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand,
      for example, 'print(a)' calls 'a.__str__()' and 'a + b' calls 'a.__add__(b)'.
    • +
    • Methods whose names start and end with two underscores are called special methods. They are executed when object is passed to a built-in function or used as an operand, for example, 'print(a)' calls 'a.__str__()' and 'a + b' calls 'a.__add__(b)'.
    • Methods decorated with '@staticmethod' receive neither 'self' nor 'cls' argument.
    • Return value of str() special method should be readable and of repr() unambiguous. If only repr() is defined, it will also be used for str().
    @@ -891,7 +891,7 @@ Z = make_dataclass('Z', [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 accepts any callable object.
  • +
  • Function field() is needed because '<attr_name>: list = []' would make a list that is shared among all instances. Its 'default_factory' argument accepts any callable object.
  • For attributes of arbitrary type use 'typing.Any'.
P = make_dataclass('P', ['x', 'y'])
@@ -1924,7 +1924,7 @@ D = enum.Enum('D', 'n
 W, H = 15, 7                               # Width and height constants.
 
 def main(screen):
-    curses.curs_set(0)                     # Makes cursor invisible.
+    curses.curs_set(0)                     # Makes the cursor invisible.
     screen.nodelay(True)                   # Makes getch() non-blocking.
     asyncio.run(main_coroutine(screen))    # Starts running asyncio code.
 
diff --git a/parse.js b/parse.js
index 668b799..7a7d19c 100755
--- a/parse.js
+++ b/parse.js
@@ -125,7 +125,7 @@ const COROUTINES =
   'W, H = 15, 7                               # Width and height constants.\n' +
   '\n' +
   'def main(screen):\n' +
-  '    curses.curs_set(0)                     # Makes cursor invisible.\n' +
+  '    curses.curs_set(0)                     # Makes the cursor invisible.\n' +
   '    screen.nodelay(True)                   # Makes getch() non-blocking.\n' +
   '    asyncio.run(main_coroutine(screen))    # Starts running asyncio code.\n' +
   '\n' +
diff --git a/pdf/remove_links.py b/pdf/remove_links.py
index d3455ee..5b8941b 100755
--- a/pdf/remove_links.py
+++ b/pdf/remove_links.py
@@ -15,6 +15,7 @@ MATCHES = {
     '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 accepts any callable object.': 'Function field() is needed because \'<attr_name>: list = []\' would make a list that is shared among all instances. Its \'default_factory\' argument accepts any callable object.',
     'Sequence iterators returned by the iter() function, such as list_iterator, etc.': 'Sequence 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.': 'Objects returned by the itertools module, such as count, repeat and cycle (p. 3).',
     'Generators returned by the generator functions and generator expressions.': 'Generators returned by the generator functions (p. 4) and generator expressions (p. 11).',