|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>December 19, 2022</aside> |
| 57 | + <aside>December 22, 2022</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
387 | 387 | <ul>
|
388 | 388 | <li><strong>Options can be generated dynamically: <code class="python hljs"><span class="hljs-string">f'<span class="hljs-subst">{<el>:{<str/int>}</span>[…]}'</span></code>.</strong></li>
|
389 | 389 | <li><strong>Adding <code class="python hljs"><span class="hljs-string">'!r'</span></code> before the colon converts object to string by calling its <a href="#class">repr()</a> method.</strong></li>
|
| 390 | +<li><strong>Adding <code class="python hljs"><span class="hljs-string">'='</span></code> before the colon prepends the expression to the result.</strong></li> |
390 | 391 | </ul>
|
391 | 392 | <div><h3 id="strings">Strings</h3><pre><code class="python language-python hljs">{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10</span>} <span class="hljs-comment"># 'abcde '</span>
|
392 | 393 | {<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># 'abc '</span>
|
|
1195 | 1196 | <li><strong>Code inside the <code class="python hljs"><span class="hljs-string">'else'</span></code> block will only be executed if <code class="python hljs"><span class="hljs-string">'try'</span></code> block had no exceptions.</strong></li>
|
1196 | 1197 | <li><strong>Code inside the <code class="python hljs"><span class="hljs-string">'finally'</span></code> block will always be executed (unless a signal is received).</strong></li>
|
1197 | 1198 | <li><strong>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).</strong></li>
|
| 1199 | +<li><strong>To catch signals use <code class="python hljs"><span class="hljs-string">'signal.signal(signal_number, <func>)'</span></code> instead.</strong></li> |
1198 | 1200 | </ul>
|
1199 | 1201 | <div><h3 id="catchingexceptions">Catching Exceptions</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">except</span> <exception>: ...
|
1200 | 1202 | <span class="hljs-keyword">except</span> <exception> <span class="hljs-keyword">as</span> <name>: ...
|
@@ -2909,7 +2911,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2909 | 2911 |
|
2910 | 2912 |
|
2911 | 2913 | <footer>
|
2912 |
| - <aside>December 19, 2022</aside> |
| 2914 | + <aside>December 22, 2022</aside> |
2913 | 2915 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2914 | 2916 | </footer>
|
2915 | 2917 |
|
|
0 commit comments