Skip to content

Commit be66e8c

Browse files
committed
Exception, Paths, Image
1 parent 9c81a49 commit be66e8c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ filename = <name>.__traceback__.tb_frame.f_code.co_filename
14381438
func_name = <name>.__traceback__.tb_frame.f_code.co_name
14391439
line = linecache.getline(filename, <name>.__traceback__.tb_lineno)
14401440
trace_str = ''.join(traceback.format_tb(<name>.__traceback__))
1441-
error_msg = ''.join(traceback.format_exception(exc_type, <name>, <name>.__traceback__))
1441+
error_msg = ''.join(traceback.format_exception(type(<name>), <name>, <name>.__traceback__))
14421442
```
14431443

14441444
### Built-in Exceptions
@@ -1672,7 +1672,7 @@ from pathlib import Path
16721672
```python
16731673
<Path> = Path(<path> [, ...]) # Accepts strings, Paths and DirEntry objects.
16741674
<Path> = <path> / <path> [/ ...] # First or second path must be a Path object.
1675-
<Path> = <Path>.resolve() # Resolves symlinks and calls <Path>.absolute().
1675+
<Path> = <Path>.resolve() # Returns absolute path with resolved symlinks.
16761676
```
16771677

16781678
```python
@@ -2799,7 +2799,7 @@ img.putdata([(int(h), 255, 255) for h in hues])
27992799
img.convert('RGB').save('test.png')
28002800
```
28012801

2802-
#### Adds noise to a PNG image:
2802+
#### Adds noise to a PNG image and displays it:
28032803
```python
28042804
from random import randint
28052805
add_noise = lambda value: max(0, min(255, value + randint(-20, 20)))

index.html

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

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

@@ -1230,7 +1230,7 @@
12301230
func_name = &lt;name&gt;.__traceback__.tb_frame.f_code.co_name
12311231
line = linecache.getline(filename, &lt;name&gt;.__traceback__.tb_lineno)
12321232
trace_str = <span class="hljs-string">''</span>.join(traceback.format_tb(&lt;name&gt;.__traceback__))
1233-
error_msg = <span class="hljs-string">''</span>.join(traceback.format_exception(exc_type, &lt;name&gt;, &lt;name&gt;.__traceback__))
1233+
error_msg = <span class="hljs-string">''</span>.join(traceback.format_exception(type(&lt;name&gt;), &lt;name&gt;, &lt;name&gt;.__traceback__))
12341234
</code></pre></div>
12351235

12361236
<div><h3 id="builtinexceptions">Built-in Exceptions</h3><pre><code class="text language-text">BaseException
@@ -1414,7 +1414,7 @@
14141414

14151415
<div><h3 id="pathobject">Path Object</h3><pre><code class="python language-python hljs">&lt;Path&gt; = Path(&lt;path&gt; [, ...]) <span class="hljs-comment"># Accepts strings, Paths and DirEntry objects.</span>
14161416
&lt;Path&gt; = &lt;path&gt; / &lt;path&gt; [/ ...] <span class="hljs-comment"># First or second path must be a Path object.</span>
1417-
&lt;Path&gt; = &lt;Path&gt;.resolve() <span class="hljs-comment"># Resolves symlinks and calls &lt;Path&gt;.absolute().</span>
1417+
&lt;Path&gt; = &lt;Path&gt;.resolve() <span class="hljs-comment"># Returns absolute path with resolved symlinks.</span>
14181418
</code></pre></div>
14191419

14201420
<pre><code class="python language-python hljs">&lt;Path&gt; = Path() <span class="hljs-comment"># Returns relative cwd. Also Path('.').</span>
@@ -2288,7 +2288,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22882288

22892289

22902290

2291-
<div><h4 id="addsnoisetoapngimage">Adds noise to a PNG image:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> randint
2291+
<div><h4 id="addsnoisetoapngimageanddisplaysit">Adds noise to a PNG image and displays it:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> random <span class="hljs-keyword">import</span> randint
22922292
add_noise = <span class="hljs-keyword">lambda</span> value: max(<span class="hljs-number">0</span>, min(<span class="hljs-number">255</span>, value + randint(<span class="hljs-number">-20</span>, <span class="hljs-number">20</span>)))
22932293
img = Image.open(<span class="hljs-string">'test.png'</span>).convert(<span class="hljs-string">'HSV'</span>)
22942294
img.putdata([(add_noise(h), s, v) <span class="hljs-keyword">for</span> h, s, v <span class="hljs-keyword">in</span> img.getdata()])
@@ -2933,7 +2933,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29332933

29342934

29352935
<footer>
2936-
<aside>July 22, 2023</aside>
2936+
<aside>July 24, 2023</aside>
29372937
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29382938
</footer>
29392939

0 commit comments

Comments
 (0)