|
56 | 56 |
|
57 | 57 | <body> |
58 | 58 | <header> |
59 | | - <aside>July 30, 2025</aside> |
| 59 | + <aside>July 31, 2025</aside> |
60 | 60 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
61 | 61 | </header> |
62 | 62 |
|
@@ -1775,7 +1775,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
1775 | 1775 | <li><strong>Sequence pattern can also be written as a tuple, either with or without the brackets.</strong></li> |
1776 | 1776 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'*<name>'</span></code> and <code class="python hljs"><span class="hljs-string">'**<name>'</span></code> in sequence/mapping patterns to bind remaining items.</strong></li> |
1777 | 1777 | <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> > <code class="python hljs"><span class="hljs-string">'as'</span></code> > <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 | 0, 2 as x if x == 2'</span></code> clause.</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> > <code class="python hljs"><span class="hljs-string">'as'</span></code> > <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 | 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> |
1780 | 1780 | </ul> |
1781 | 1781 | <div><h3 id="example-2">Example</h3><pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path |
@@ -1840,11 +1840,11 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
1840 | 1840 | <pre><code class="python language-python hljs"><list> = dir(<obj>) <span class="hljs-comment"># Returns names of object's attributes (including methods).</span> |
1841 | 1841 | <dict> = vars(<obj>) <span class="hljs-comment"># Returns dict of writable attributes. Also <obj>.__dict__.</span> |
1842 | 1842 | <bool> = hasattr(<obj>, <span class="hljs-string">'<name>'</span>) <span class="hljs-comment"># Checks if object possesses attribute with passed name.</span> |
1843 | | -value = getattr(<obj>, <span class="hljs-string">'<name>'</span>) <span class="hljs-comment"># Returns object's attribute or raises AttributeError.</span> |
| 1843 | +value = getattr(<obj>, <span class="hljs-string">'<name>'</span>) <span class="hljs-comment"># Returns the object's attribute or raises AttributeError.</span> |
1844 | 1844 | setattr(<obj>, <span class="hljs-string">'<name>'</span>, value) <span class="hljs-comment"># Sets attribute. Only works on objects with __dict__ attr.</span> |
1845 | 1845 | delattr(<obj>, <span class="hljs-string">'<name>'</span>) <span class="hljs-comment"># Deletes attribute from __dict__. Also `del <obj>.<name>`.</span> |
1846 | 1846 | </code></pre> |
1847 | | -<pre><code class="python language-python hljs"><Sig> = inspect.signature(<func>) <span class="hljs-comment"># Returns a Signature object of the passed function.</span> |
| 1847 | +<pre><code class="python language-python hljs"><Sig> = inspect.signature(<func>) <span class="hljs-comment"># Returns Signature object of the passed function or class.</span> |
1848 | 1848 | <dict> = <Sig>.parameters <span class="hljs-comment"># Returns dict of Parameters. Also <Sig>.return_annotation.</span> |
1849 | 1849 | <memb> = <Param>.kind <span class="hljs-comment"># Returns ParameterKind member (Parameter.KEYWORD_ONLY, …).</span> |
1850 | 1850 | <type> = <Param>.annotation <span class="hljs-comment"># Returns Parameter.empty if missing. Also <Param>.default.</span> |
@@ -2934,7 +2934,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
2934 | 2934 |
|
2935 | 2935 |
|
2936 | 2936 | <footer> |
2937 | | - <aside>July 30, 2025</aside> |
| 2937 | + <aside>July 31, 2025</aside> |
2938 | 2938 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
2939 | 2939 | </footer> |
2940 | 2940 |
|
|
0 commit comments