|
56 | 56 |
|
57 | 57 | <body> |
58 | 58 | <header> |
59 | | - <aside>January 25, 2026</aside> |
| 59 | + <aside>January 31, 2026</aside> |
60 | 60 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
61 | 61 | </header> |
62 | 62 |
|
|
467 | 467 | <ul> |
468 | 468 | <li><strong><code class="python hljs"><span class="hljs-string">'int(<str>)'</span></code> and <code class="python hljs"><span class="hljs-string">'float(<str>)'</span></code> raise ValueError exception if string is malformed.</strong></li> |
469 | 469 | <li><strong>Decimal objects store numbers exactly, unlike most floats where <code class="python hljs"><span class="hljs-string">'1.1 + 2.2 != 3.3'</span></code>.</strong></li> |
470 | | -<li><strong>Floats can be compared with: <code class="python hljs"><span class="hljs-string">'math.isclose(<float>, <float>, rel_tol=1e-09)'</span></code>.</strong></li> |
| 470 | +<li><strong>Floats can be compared with: <code class="python hljs"><span class="hljs-string">'math.isclose(<float>, <float>, rel_tol=1e-9)'</span></code>.</strong></li> |
471 | 471 | <li><strong>Precision of decimal operations is set with: <code class="python hljs"><span class="hljs-string">'decimal.getcontext().prec = <int>'</span></code>.</strong></li> |
472 | 472 | <li><strong>Bools can be used anywhere ints can, since bool is a subclass of int: <code class="python hljs"><span class="hljs-string">'True + 1 == 2'</span></code>.</strong></li> |
473 | 473 | </ul> |
474 | 474 | <div><h3 id="builtinfunctions">Built-in Functions</h3><pre><code class="python language-python hljs"><num> = pow(<num>, <num>) <span class="hljs-comment"># E.g. `pow(3, 4) == 3 ** 4 == 81`.</span> |
475 | | -<num> = abs(<num>) <span class="hljs-comment"># E.g. `abs(complex(3, 4)) == 5`.</span> |
| 475 | +<num> = abs(<num>) <span class="hljs-comment"># E.g. `abs(-50) == abs(50) == 50`.</span> |
476 | 476 | <num> = round(<num> [, ±ndigits]) <span class="hljs-comment"># E.g. `round(123.45, -1) == 120`.</span> |
477 | 477 | <num> = min(<coll_of_nums>) <span class="hljs-comment"># Also `max(<num>, <num> [, ...])`.</span> |
478 | 478 | <num> = sum(<coll_of_nums>) <span class="hljs-comment"># Also `math.prod(<coll_of_nums>)`.</span> |
|
1338 | 1338 | <li><strong><code class="python hljs"><span class="hljs-string">'encoding=None'</span></code> means that the default encoding is used, which is platform dependent. Best practice is to use <code class="python hljs"><span class="hljs-string">'encoding="utf-8"'</span></code> until it becomes the default (Python 3.15).</strong></li> |
1339 | 1339 | <li><strong><code class="python hljs"><span class="hljs-string">'newline=None'</span></code> means all different end of line combinations are converted to '\n' on read, while on write all '\n' characters are converted to system's default line separator.</strong></li> |
1340 | 1340 | <li><strong><code class="python hljs"><span class="hljs-string">'newline=""'</span></code> means no conversions take place, but input is still broken into chunks by readline() on every '\n', '\r' and '\r\n'. Passing <code class="python hljs"><span class="hljs-string">'newline="\n"'</span></code> breaks input only on '\n'.</strong></li> |
1341 | | -<li><strong><code class="python hljs"><span class="hljs-string">'newline="\r\n"'</span></code> converts every '\n' to '\r\n' on write and breaks input only on '\r\n'.</strong></li> |
| 1341 | +<li><strong><code class="python hljs"><span class="hljs-string">'newline="\r\n"'</span></code> breaks input only on '\r\n' and converts every '\n' to '\r\n' on write.</strong></li> |
1342 | 1342 | </ul> |
1343 | 1343 | <div><h3 id="modes">Modes</h3><ul> |
1344 | 1344 | <li><strong><code class="python hljs"><span class="hljs-string">'r'</span></code> - Read text from the file (the default option).</strong></li> |
@@ -2276,8 +2276,8 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
2276 | 2276 | <Image>.putdata(<list/ImgCore>) <span class="hljs-comment"># Updates pixels with a copy of passed sequence.</span> |
2277 | 2277 | <Image>.paste(<Image>, (x, y)) <span class="hljs-comment"># Draws passed image at the specified location.</span> |
2278 | 2278 | </code></pre> |
2279 | | -<pre><code class="python language-python hljs"><Image> = <Image>.filter(<Filter>) <span class="hljs-comment"># E.g. `<Image>.filter(ImageFilter.FIND_EDGES)`.</span> |
2280 | | -<Image> = <Enhance>.enhance(<float>) <span class="hljs-comment"># E.g. `ImageEnhance.Color(<Image>).enhance(2)`.</span> |
| 2279 | +<pre><code class="python language-python hljs"><Image> = <Image>.filter(<Filter>) <span class="hljs-comment"># Accepts ImageFilter.BLUR/SHARPEN/FIND_EDGES/….</span> |
| 2280 | +<Image> = <Enhance>.enhance(<float>) <span class="hljs-comment"># E.g. `ImageEnhance.Contrast/Color/…(<Image>)`.</span> |
2281 | 2281 | </code></pre> |
2282 | 2282 | <pre><code class="python language-python hljs"><array> = np.array(<Image>) <span class="hljs-comment"># Creates a 2d or 3d NumPy array from the image.</span> |
2283 | 2283 | <Image> = Image.fromarray(np.uint8(<array>)) <span class="hljs-comment"># Use `<array>.clip(0, 255)` to clip the values.</span> |
@@ -2935,7 +2935,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
2935 | 2935 |
|
2936 | 2936 |
|
2937 | 2937 | <footer> |
2938 | | - <aside>January 25, 2026</aside> |
| 2938 | + <aside>January 31, 2026</aside> |
2939 | 2939 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
2940 | 2940 | </footer> |
2941 | 2941 |
|
|
0 commit comments