Skip to content

Commit df39e34

Browse files
committed
Match, Logging
1 parent fc2c3f7 commit df39e34

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,8 +2144,8 @@ match <object/expression>:
21442144
* **Sequence pattern can also be written as a tuple, either with or without the brackets.**
21452145
* **Use `'*<name>'` and `'**<name>'` in sequence/mapping patterns to bind remaining items.**
21462146
* **Sequence pattern must match all items of the collection, while mapping pattern does not.**
2147-
* **Patterns can be surrounded with brackets to override their precedence: `'|'` > `'as'` > `','`. For example, `'[1, 2]'` gets caught by the `'case 1|2, 2|3 as x if x == 2:'` clause.**
2148-
* **All names that are bound in the matching case, as well as variables initialized in its block, are visible after the match statement (only the function block delimits scope).**
2147+
* **Patterns can be surrounded with brackets to override their precedence: `'|'` > `'as'` > `','`. For example, `'[1, 2]'` is matched by the `'case 1|2, 2|3 as x if x == 2:'` block.**
2148+
* **All names that are bound in the matching case, as well as variables initialized in its body, are visible after the match statement (only function block delimits scope).**
21492149

21502150
### Example
21512151
```python
@@ -2185,10 +2185,10 @@ log.basicConfig(
21852185

21862186
```python
21872187
<Formatter> = log.Formatter('<format>') # Formats messages according to format str.
2188-
<Handler> = log.FileHandler(<path>, mode='a') # Creates a handler. Also `encoding=None`.
2189-
<Handler>.setFormatter(<Formatter>) # Assigns the formatter to the handler.
2190-
<Handler>.setLevel(<int/str>) # It will process all messages by default.
2191-
<Logger>.addHandler(<Handler>) # Appends handler to logger's 'handlers'.
2188+
<Handler> = log.FileHandler(<path>, mode='a') # Appends to file. Also `encoding=None`.
2189+
<Handler>.setFormatter(<Formatter>) # Only outputs bare messages by default.
2190+
<Handler>.setLevel(<int/str>) # Prints or saves every message by default.
2191+
<Logger>.addHandler(<Handler>) # Logger can have more than one handler.
21922192
<Logger>.setLevel(<int/str>) # What is sent to its/ancestors' handlers.
21932193
<Logger>.propagate = <bool> # Cuts off ancestors' handlers if False.
21942194
```

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
17751775
<li><strong>Sequence pattern can also be written as a tuple, either with or without the brackets.</strong></li>
17761776
<li><strong>Use <code class="python hljs"><span class="hljs-string">'*&lt;name&gt;'</span></code> and <code class="python hljs"><span class="hljs-string">'**&lt;name&gt;'</span></code> in sequence/mapping patterns to bind remaining items.</strong></li>
17771777
<li><strong>Sequence pattern must match all items of the collection, while mapping pattern does not.</strong></li>
1778-
<li><strong>Patterns can be surrounded with brackets to override their precedence: <code class="python hljs"><span class="hljs-string">'|'</span></code> &gt; <code class="python hljs"><span class="hljs-string">'as'</span></code> &gt; <code class="python hljs"><span class="hljs-string">','</span></code>. For example, <code class="python hljs"><span class="hljs-string">'[1, 2]'</span></code> gets caught by the <code class="python hljs"><span class="hljs-string">'case 1|2, 2|3 as x if x == 2:'</span></code> clause.</strong></li>
1779-
<li><strong>All names that are bound in the matching case, as well as variables initialized in its block, are visible after the match statement (only the function block delimits scope).</strong></li>
1778+
<li><strong>Patterns can be surrounded with brackets to override their precedence: <code class="python hljs"><span class="hljs-string">'|'</span></code> &gt; <code class="python hljs"><span class="hljs-string">'as'</span></code> &gt; <code class="python hljs"><span class="hljs-string">','</span></code>. For example, <code class="python hljs"><span class="hljs-string">'[1, 2]'</span></code> is matched by the <code class="python hljs"><span class="hljs-string">'case 1|2, 2|3 as x if x == 2:'</span></code> block.</strong></li>
1779+
<li><strong>All names that are bound in the matching case, as well as variables initialized in its body, are visible after the match statement (only function block delimits scope).</strong></li>
17801780
</ul>
17811781
<div><h3 id="example-2">Example</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
17821782
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">match</span> Path(<span class="hljs-string">'/home/gto/python-cheatsheet/README.md'</span>):
@@ -1805,10 +1805,10 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
18051805
</code></pre></div>
18061806

18071807
<pre><code class="python language-python hljs">&lt;Formatter&gt; = log.Formatter(<span class="hljs-string">'&lt;format&gt;'</span>) <span class="hljs-comment"># Formats messages according to format str.</span>
1808-
&lt;Handler&gt; = log.FileHandler(&lt;path&gt;, mode=<span class="hljs-string">'a'</span>) <span class="hljs-comment"># Creates a handler. Also `encoding=None`.</span>
1809-
&lt;Handler&gt;.setFormatter(&lt;Formatter&gt;) <span class="hljs-comment"># Assigns the formatter to the handler.</span>
1810-
&lt;Handler&gt;.setLevel(&lt;int/str&gt;) <span class="hljs-comment"># It will process all messages by default.</span>
1811-
&lt;Logger&gt;.addHandler(&lt;Handler&gt;) <span class="hljs-comment"># Appends handler to logger's 'handlers'.</span>
1808+
&lt;Handler&gt; = log.FileHandler(&lt;path&gt;, mode=<span class="hljs-string">'a'</span>) <span class="hljs-comment"># Appends to file. Also `encoding=None`.</span>
1809+
&lt;Handler&gt;.setFormatter(&lt;Formatter&gt;) <span class="hljs-comment"># Only outputs bare messages by default.</span>
1810+
&lt;Handler&gt;.setLevel(&lt;int/str&gt;) <span class="hljs-comment"># Prints or saves every message by default.</span>
1811+
&lt;Logger&gt;.addHandler(&lt;Handler&gt;) <span class="hljs-comment"># Logger can have more than one handler.</span>
18121812
&lt;Logger&gt;.setLevel(&lt;int/str&gt;) <span class="hljs-comment"># What is sent to its/ancestors' handlers.</span>
18131813
&lt;Logger&gt;.propagate = &lt;bool&gt; <span class="hljs-comment"># Cuts off ancestors' handlers if False.</span>
18141814
</code></pre>

0 commit comments

Comments
 (0)