|
54 | 54 |
|
55 | 55 | <body> |
56 | 56 | <header> |
57 | | - <aside>June 27, 2022</aside> |
| 57 | + <aside>July 13, 2022</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
59 | 59 | </header> |
60 | 60 |
|
|
182 | 182 | </code></pre></div> |
183 | 183 |
|
184 | 184 |
|
185 | | -<div><h2 id="tuple"><a href="#tuple" name="tuple">#</a>Tuple</h2><p><strong>Tuple is an immutable and hashable list.</strong></p><pre><code class="python language-python hljs"><tuple> = () <span class="hljs-comment"># Or: tuple()</span> |
186 | | -<tuple> = (<el>,) <span class="hljs-comment"># Or: <el>,</span> |
187 | | -<tuple> = (<el_1>, <el_2> [, ...]) <span class="hljs-comment"># Or: <el_1>, <el_2> [, ...]</span> |
| 185 | +<div><h2 id="tuple"><a href="#tuple" name="tuple">#</a>Tuple</h2><p><strong>Tuple is an immutable and hashable list.</strong></p><pre><code class="python language-python hljs"><tuple> = () <span class="hljs-comment"># Empty tuple.</span> |
| 186 | +<tuple> = (<el>,) <span class="hljs-comment"># Or: <el>,</span> |
| 187 | +<tuple> = (<el_1>, <el_2> [, ...]) <span class="hljs-comment"># Or: <el_1>, <el_2> [, ...]</span> |
188 | 188 | </code></pre></div> |
189 | 189 |
|
190 | 190 |
|
|
198 | 198 | <span class="hljs-number">1</span> |
199 | 199 | <span class="hljs-meta">>>> </span>getattr(p, <span class="hljs-string">'y'</span>) |
200 | 200 | <span class="hljs-number">2</span> |
201 | | -<span class="hljs-meta">>>> </span>p._fields <span class="hljs-comment"># Or: Point._fields</span> |
202 | | -(<span class="hljs-string">'x'</span>, <span class="hljs-string">'y'</span>) |
203 | 201 | </code></pre></div> |
204 | 202 |
|
205 | 203 |
|
206 | | -<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><pre><code class="python language-python hljs"><range> = range(to_exclusive) |
207 | | -<range> = range(from_inclusive, to_exclusive) |
208 | | -<range> = range(from_inclusive, to_exclusive, ±step_size) |
| 204 | +<div><h2 id="range"><a href="#range" name="range">#</a>Range</h2><p><strong>An immutable and hashable sequence of evenly spaced integers.</strong></p><pre><code class="python language-python hljs"><range> = range(to_exclusive) <span class="hljs-comment"># `list(range(3)) == [0, 1, 2]`</span> |
| 205 | +<range> = range(from_inclusive, to_exclusive) <span class="hljs-comment"># `list(range(1, 4)) == [1, 2, 3]`</span> |
| 206 | +<range> = range(from_inclusive, to_exclusive, ±step) <span class="hljs-comment"># `list(range(3, 0, -1)) == [3, 2, 1]`</span> |
209 | 207 | </code></pre></div> |
210 | 208 |
|
| 209 | + |
211 | 210 | <pre><code class="python language-python hljs">from_inclusive = <range>.start |
212 | 211 | to_exclusive = <range>.stop |
213 | 212 | </code></pre> |
|
229 | 228 | <iter> = cycle(<collection>) <span class="hljs-comment"># Repeats the sequence endlessly.</span> |
230 | 229 | </code></pre> |
231 | 230 | <pre><code class="python language-python hljs"><iter> = chain(<coll_1>, <coll_2> [, ...]) <span class="hljs-comment"># Empties collections in order (figuratively).</span> |
232 | | -<iter> = chain.from_iterable(<collection>) <span class="hljs-comment"># Empties collections inside a collection in order.</span> |
| 231 | +<iter> = chain.from_iterable(<coll>) <span class="hljs-comment"># Empties collections inside a collection in order.</span> |
233 | 232 | </code></pre> |
234 | 233 | <pre><code class="python language-python hljs"><iter> = islice(<coll>, to_exclusive) <span class="hljs-comment"># Only returns first 'to_exclusive' elements.</span> |
235 | | -<iter> = islice(<coll>, from_inclusive, …) <span class="hljs-comment"># `to_exclusive, step_size`.</span> |
| 234 | +<iter> = islice(<coll>, from_inclusive, …) <span class="hljs-comment"># `to_exclusive, +step`.</span> |
236 | 235 | </code></pre> |
237 | 236 | <div><h2 id="generator"><a href="#generator" name="generator">#</a>Generator</h2><ul> |
238 | 237 | <li><strong>Any function that contains a yield statement returns a generator.</strong></li> |
@@ -2901,7 +2900,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment |
2901 | 2900 |
|
2902 | 2901 |
|
2903 | 2902 | <footer> |
2904 | | - <aside>June 27, 2022</aside> |
| 2903 | + <aside>July 13, 2022</aside> |
2905 | 2904 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a> |
2906 | 2905 | </footer> |
2907 | 2906 |
|
|
0 commit comments