From be66e8cbb39aeaac75315212b5b3b3ab112f839c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 24 Jul 2023 12:39:14 +0200 Subject: [PATCH] Exception, Paths, Image --- README.md | 6 +++--- index.html | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 85ab581..9f03646 100644 --- a/README.md +++ b/README.md @@ -1438,7 +1438,7 @@ filename = .__traceback__.tb_frame.f_code.co_filename func_name = .__traceback__.tb_frame.f_code.co_name line = linecache.getline(filename, .__traceback__.tb_lineno) trace_str = ''.join(traceback.format_tb(.__traceback__)) -error_msg = ''.join(traceback.format_exception(exc_type, , .__traceback__)) +error_msg = ''.join(traceback.format_exception(type(), , .__traceback__)) ``` ### Built-in Exceptions @@ -1672,7 +1672,7 @@ from pathlib import Path ```python = Path( [, ...]) # Accepts strings, Paths and DirEntry objects. = / [/ ...] # First or second path must be a Path object. - = .resolve() # Resolves symlinks and calls .absolute(). + = .resolve() # Returns absolute path with resolved symlinks. ``` ```python @@ -2799,7 +2799,7 @@ img.putdata([(int(h), 255, 255) for h in hues]) img.convert('RGB').save('test.png') ``` -#### Adds noise to a PNG image: +#### Adds noise to a PNG image and displays it: ```python from random import randint add_noise = lambda value: max(0, min(255, value + randint(-20, 20))) diff --git a/index.html b/index.html index c425e23..2e2a8e7 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1230,7 +1230,7 @@ filename = <name>.__traceback__.tb_frame.f_code.co_filename func_name = <name>.__traceback__.tb_frame.f_code.co_name line = linecache.getline(filename, <name>.__traceback__.tb_lineno) trace_str = ''.join(traceback.format_tb(<name>.__traceback__)) -error_msg = ''.join(traceback.format_exception(exc_type, <name>, <name>.__traceback__)) +error_msg = ''.join(traceback.format_exception(type(<name>), <name>, <name>.__traceback__))

Built-in Exceptions

BaseException
@@ -1414,7 +1414,7 @@ value = args.<name>
 
 

Path Object

<Path> = Path(<path> [, ...])       # Accepts strings, Paths and DirEntry objects.
 <Path> = <path> / <path> [/ ...]    # First or second path must be a Path object.
-<Path> = <Path>.resolve()           # Resolves symlinks and calls <Path>.absolute().
+<Path> = <Path>.resolve()           # Returns absolute path with resolved symlinks.
 
<Path> = Path()                     # Returns relative cwd. Also Path('.').
@@ -2288,7 +2288,7 @@ img.convert('RGB').save(Adds noise to a PNG image:
from random import randint
+

Adds noise to a PNG image and displays it:

from random import randint
 add_noise = lambda value: max(0, min(255, value + randint(-20, 20)))
 img = Image.open('test.png').convert('HSV')
 img.putdata([(add_noise(h), s, v) for h, s, v in img.getdata()])
@@ -2933,7 +2933,7 @@ $ pyinstaller script.py --add-data '<path>:.'