Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 212b127

Browse files
committed
Format, Exceptions
1 parent da2d6d1 commit 212b127

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ Format
416416
```
417417
* **Options can be generated dynamically: `f'{<el>:{<str/int>}[…]}'`.**
418418
* **Adding `'!r'` before the colon converts object to string by calling its [repr()](#class) method.**
419+
* **Adding `'='` before the colon prepends the expression to the result.**
419420

420421
### Strings
421422
```python
@@ -1393,6 +1394,7 @@ finally:
13931394
* **Code inside the `'else'` block will only be executed if `'try'` block had no exceptions.**
13941395
* **Code inside the `'finally'` block will always be executed (unless a signal is received).**
13951396
* **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).**
1397+
* **To catch signals use `'signal.signal(signal_number, <func>)'` instead.**
13961398

13971399
### Catching Exceptions
13981400
```python

index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>December 19, 2022</aside>
57+
<aside>December 22, 2022</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -387,6 +387,7 @@
387387
<ul>
388388
<li><strong>Options can be generated dynamically: <code class="python hljs"><span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;:{&lt;str/int&gt;}</span>[…]}'</span></code>.</strong></li>
389389
<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>
390391
</ul>
391392
<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>
392393
{<span class="hljs-string">'abcde'</span>:<span class="hljs-number">10.3</span>} <span class="hljs-comment"># 'abc '</span>
@@ -1195,6 +1196,7 @@
11951196
<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>
11961197
<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>
11971198
<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, &lt;func&gt;)'</span></code> instead.</strong></li>
11981200
</ul>
11991201
<div><h3 id="catchingexceptions">Catching Exceptions</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">except</span> &lt;exception&gt;: ...
12001202
<span class="hljs-keyword">except</span> &lt;exception&gt; <span class="hljs-keyword">as</span> &lt;name&gt;: ...
@@ -2909,7 +2911,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29092911

29102912

29112913
<footer>
2912-
<aside>December 19, 2022</aside>
2914+
<aside>December 22, 2022</aside>
29132915
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29142916
</footer>
29152917

0 commit comments

Comments
 (0)