From 2f3b3a47363157a09575ac08492e3666b2016da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 25 Dec 2022 00:39:59 +0100 Subject: [PATCH] String, Format, Exceptions --- README.md | 5 ++--- index.html | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6d4448b..bd56ebb 100644 --- a/README.md +++ b/README.md @@ -344,7 +344,7 @@ String | isdecimal() | | | | | yes | +---------------+----------+----------+----------+----------+----------+ ``` -* **Also: `'isspace()'` checks for `'[ \t\n\r\f\v\x1c-\x1f\x85\u2000…]'`.** +* **`'isspace()'` checks for whitespaces: `'[ \t\n\r\f\v\x1c-\x1f\x85\xa0\u1680…]'`.** Regex @@ -416,7 +416,6 @@ Format ``` * **Options can be generated dynamically: `f'{:{}[…]}'`.** * **Adding `'!r'` before the colon converts object to string by calling its [repr()](#class) method.** -* **Adding `'='` before the colon prepends the expression to the result.** ### Strings ```python @@ -1394,7 +1393,7 @@ finally: * **Code inside the `'else'` block will only be executed if `'try'` block had no exceptions.** * **Code inside the `'finally'` block will always be executed (unless a signal is received).** * **All variables that are initialized in executed blocks are also visible in all subsequent blocks, as well as outside the try/except clause (only function blocks delimit scope).** -* **To catch signals use `'signal.signal(signal_number, )'` instead.** +* **To catch signals use `'signal.signal(signal_number, )'`.** ### Catching Exceptions ```python diff --git a/index.html b/index.html index 8255ca2..3d72401 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -327,7 +327,7 @@ Point(x=1, y=2
    -
  • Also: 'isspace()' checks for '[ \t\n\r\f\v\x1c-\x1f\x85\u2000…]'.
  • +
  • 'isspace()' checks for whitespaces: '[ \t\n\r\f\v\x1c-\x1f\x85\xa0\u1680…]'.

#Regex

import re
 <str>   = re.sub(<regex>, new, text, count=0)  # Substitutes all occurrences with 'new'.
@@ -387,7 +387,6 @@ Point(x=1, y=2
 
  • Options can be generated dynamically: f'{<el>:{<str/int>}[…]}'.
  • Adding '!r' before the colon converts object to string by calling its repr() method.
  • -
  • Adding '=' before the colon prepends the expression to the result.

Strings

{'abcde':10}                             # 'abcde     '
 {'abcde':10.3}                           # 'abc       '
@@ -1196,7 +1195,7 @@ LogicOp = Enum('LogicOp', {'else' block will only be executed if 'try' block had no exceptions.
 
  • Code inside the 'finally' block will always be executed (unless a signal is received).
  • All variables that are initialized in executed blocks are also visible in all subsequent blocks, as well as outside the try/except clause (only function blocks delimit scope).
  • -
  • To catch signals use 'signal.signal(signal_number, <func>)' instead.
  • +
  • To catch signals use 'signal.signal(signal_number, <func>)'.
  • Catching Exceptions

    except <exception>: ...
     except <exception> as <name>: ...
    @@ -2911,7 +2910,7 @@ $ pyinstaller script.py --add-data '<path>:.'