|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>July 20, 2022</aside> |
| 57 | + <aside>July 22, 2022</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
1098 | 1098 |
|
1099 | 1099 |
|
1100 | 1100 | <div><h4 id="discrepanciesbetweenglossarydefinitionsandabstractbaseclasses">Discrepancies between glossary definitions and abstract base classes:</h4><ul>
|
1101 |
| -<li><strong>Glossary defines iterable as any object with iter() or getitem() and sequence as any object with len() and getitem(). It does not define collection.</strong></li> |
| 1101 | +<li><strong>Glossary defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.</strong></li> |
1102 | 1102 | <li><strong>Passing ABC Iterable to isinstance() or issubclass() checks whether object/class has method iter(), while ABC Collection checks for iter(), contains() and len().</strong></li>
|
1103 | 1103 | </ul></div>
|
1104 | 1104 |
|
|
1618 | 1618 |
|
1619 | 1619 | <div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs"><bytes> = bytes(<coll_of_ints>) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
|
1620 | 1620 | <bytes> = bytes(<str>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: <str>.encode('utf-8')</span>
|
1621 |
| -<bytes> = <int>.to_bytes(n_bytes, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span> |
| 1621 | +<bytes> = <int>.to_bytes(n_bytes, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span> |
1622 | 1622 | <bytes> = bytes.fromhex(<span class="hljs-string">'<hex>'</span>) <span class="hljs-comment"># Hex pairs can be separated by whitespaces.</span>
|
1623 | 1623 | </code></pre></div>
|
1624 | 1624 |
|
1625 | 1625 | <div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs"><list> = list(<bytes>) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
|
1626 | 1626 | <str> = str(<bytes>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: <bytes>.decode('utf-8')</span>
|
1627 |
| -<int> = int.from_bytes(<bytes>, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span> |
| 1627 | +<int> = int.from_bytes(<bytes>, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span> |
1628 | 1628 | <span class="hljs-string">'<hex>'</span> = <bytes>.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=<str>`.</span>
|
1629 | 1629 | </code></pre></div>
|
1630 | 1630 |
|
@@ -1708,7 +1708,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
1708 | 1708 |
|
1709 | 1709 | <pre><code class="python language-python hljs"><list> = list(<mview>) <span class="hljs-comment"># Returns a list of ints or floats.</span>
|
1710 | 1710 | <str> = str(<mview>, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats mview as a bytes object.</span>
|
1711 |
| -<int> = int.from_bytes(<mview>, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span> |
| 1711 | +<int> = int.from_bytes(<mview>, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span> |
1712 | 1712 | <span class="hljs-string">'<hex>'</span> = <mview>.hex() <span class="hljs-comment"># Treats mview as a bytes object.</span>
|
1713 | 1713 | </code></pre>
|
1714 | 1714 | <div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><p><strong>A thread-safe list with efficient appends and pops from either side. Pronounced "deck".</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque
|
@@ -1739,7 +1739,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
1739 | 1739 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'kwargs=<dict>'</span></code> to pass keyword arguments to the function.</strong></li>
|
1740 | 1740 | <li><strong>Use <code class="python hljs"><span class="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
|
1741 | 1741 | </ul>
|
1742 |
| -<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs"><lock> = RLock() <span class="hljs-comment"># Lock that can only be released by the owner.</span> |
| 1742 | +<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs"><lock> = RLock() <span class="hljs-comment"># Lock that can only be released by acquirer.</span> |
1743 | 1743 | <lock>.acquire() <span class="hljs-comment"># Waits for the lock to be available.</span>
|
1744 | 1744 | <lock>.release() <span class="hljs-comment"># Makes the lock available again.</span>
|
1745 | 1745 | </code></pre></div>
|
@@ -2905,7 +2905,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2905 | 2905 |
|
2906 | 2906 |
|
2907 | 2907 | <footer>
|
2908 |
| - <aside>July 20, 2022</aside> |
| 2908 | + <aside>July 22, 2022</aside> |
2909 | 2909 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2910 | 2910 | </footer>
|
2911 | 2911 |
|
|
0 commit comments