Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1fc152

Browse files
committed
Iterable duck types, Bytes, Threading
1 parent d5d65fb commit d1fc152

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ class MySequence:
12791279
```
12801280

12811281
#### Discrepancies between glossary definitions and abstract base classes:
1282-
* **Glossary defines iterable as any object with iter() or getitem() and sequence as any object with len() and getitem(). It does not define collection.**
1282+
* **Glossary defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.**
12831283
* **Passing ABC Iterable to isinstance() or issubclass() checks whether object/class has method iter(), while ABC Collection checks for iter(), contains() and len().**
12841284

12851285
### ABC Sequence
@@ -1946,15 +1946,15 @@ Bytes
19461946
```python
19471947
<bytes> = bytes(<coll_of_ints>) # Ints must be in range from 0 to 255.
19481948
<bytes> = bytes(<str>, 'utf-8') # Or: <str>.encode('utf-8')
1949-
<bytes> = <int>.to_bytes(n_bytes, …) # `byteorder='big/little', signed=False`.
1949+
<bytes> = <int>.to_bytes(n_bytes, …) # `byteorder='little/big', signed=False`.
19501950
<bytes> = bytes.fromhex('<hex>') # Hex pairs can be separated by whitespaces.
19511951
```
19521952

19531953
### Decode
19541954
```python
19551955
<list> = list(<bytes>) # Returns ints in range from 0 to 255.
19561956
<str> = str(<bytes>, 'utf-8') # Or: <bytes>.decode('utf-8')
1957-
<int> = int.from_bytes(<bytes>, …) # `byteorder='big/little', signed=False`.
1957+
<int> = int.from_bytes(<bytes>, …) # `byteorder='little/big', signed=False`.
19581958
'<hex>' = <bytes>.hex() # Returns hex pairs. Accepts `sep=<str>`.
19591959
```
19601960

@@ -2054,7 +2054,7 @@ Memory View
20542054
```python
20552055
<list> = list(<mview>) # Returns a list of ints or floats.
20562056
<str> = str(<mview>, 'utf-8') # Treats mview as a bytes object.
2057-
<int> = int.from_bytes(<mview>, …) # `byteorder='big/little', signed=False`.
2057+
<int> = int.from_bytes(<mview>, …) # `byteorder='little/big', signed=False`.
20582058
'<hex>' = <mview>.hex() # Treats mview as a bytes object.
20592059
```
20602060

@@ -2097,7 +2097,7 @@ from concurrent.futures import ThreadPoolExecutor
20972097

20982098
### Lock
20992099
```python
2100-
<lock> = RLock() # Lock that can only be released by the owner.
2100+
<lock> = RLock() # Lock that can only be released by acquirer.
21012101
<lock>.acquire() # Waits for the lock to be available.
21022102
<lock>.release() # Makes the lock available again.
21032103
```

index.html

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

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

@@ -1098,7 +1098,7 @@
10981098

10991099

11001100
<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>
11021102
<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>
11031103
</ul></div>
11041104

@@ -1618,13 +1618,13 @@
16181618

16191619
<div><h3 id="encode-1">Encode</h3><pre><code class="python language-python hljs">&lt;bytes&gt; = bytes(&lt;coll_of_ints&gt;) <span class="hljs-comment"># Ints must be in range from 0 to 255.</span>
16201620
&lt;bytes&gt; = bytes(&lt;str&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;str&gt;.encode('utf-8')</span>
1621-
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span>
1621+
&lt;bytes&gt; = &lt;int&gt;.to_bytes(n_bytes, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span>
16221622
&lt;bytes&gt; = bytes.fromhex(<span class="hljs-string">'&lt;hex&gt;'</span>) <span class="hljs-comment"># Hex pairs can be separated by whitespaces.</span>
16231623
</code></pre></div>
16241624

16251625
<div><h3 id="decode-1">Decode</h3><pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;bytes&gt;) <span class="hljs-comment"># Returns ints in range from 0 to 255.</span>
16261626
&lt;str&gt; = str(&lt;bytes&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Or: &lt;bytes&gt;.decode('utf-8')</span>
1627-
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span>
1627+
&lt;int&gt; = int.from_bytes(&lt;bytes&gt;, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span>
16281628
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;bytes&gt;.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=&lt;str&gt;`.</span>
16291629
</code></pre></div>
16301630

@@ -1708,7 +1708,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
17081708

17091709
<pre><code class="python language-python hljs">&lt;list&gt; = list(&lt;mview&gt;) <span class="hljs-comment"># Returns a list of ints or floats.</span>
17101710
&lt;str&gt; = str(&lt;mview&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats mview as a bytes object.</span>
1711-
&lt;int&gt; = int.from_bytes(&lt;mview&gt;, …) <span class="hljs-comment"># `byteorder='big/little', signed=False`.</span>
1711+
&lt;int&gt; = int.from_bytes(&lt;mview&gt;, …) <span class="hljs-comment"># `byteorder='little/big', signed=False`.</span>
17121712
<span class="hljs-string">'&lt;hex&gt;'</span> = &lt;mview&gt;.hex() <span class="hljs-comment"># Treats mview as a bytes object.</span>
17131713
</code></pre>
17141714
<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
17391739
<li><strong>Use <code class="python hljs"><span class="hljs-string">'kwargs=&lt;dict&gt;'</span></code> to pass keyword arguments to the function.</strong></li>
17401740
<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>
17411741
</ul>
1742-
<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs">&lt;lock&gt; = 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">&lt;lock&gt; = RLock() <span class="hljs-comment"># Lock that can only be released by acquirer.</span>
17431743
&lt;lock&gt;.acquire() <span class="hljs-comment"># Waits for the lock to be available.</span>
17441744
&lt;lock&gt;.release() <span class="hljs-comment"># Makes the lock available again.</span>
17451745
</code></pre></div>
@@ -2905,7 +2905,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29052905

29062906

29072907
<footer>
2908-
<aside>July 20, 2022</aside>
2908+
<aside>July 22, 2022</aside>
29092909
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29102910
</footer>
29112911

0 commit comments

Comments
 (0)