Skip to content

Commit

Permalink
Iterable duck types, Deque, Introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
gto76 committed Dec 18, 2024
1 parent 07477fc commit 1329399
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1294,8 +1294,8 @@ class MySequence:
```

#### Discrepancies between glossary definitions and abstract base classes:
* **Python's glossary defines iterable as any object with iter() or getitem() and sequence as any object with getitem() and len(). It does not define collection.**
* **Passing ABC Iterable to isinstance() or issubclass() checks whether object/class has method iter(), while ABC Collection checks for iter(), contains() and len().**
* **Python's glossary defines iterable as any object with special methods iter() and/or getitem() and sequence as any object with getitem() and len(). It doesn't define collection.**
* **Passing ABC Iterable to isinstance() or issubclass() only checks whether object/class has special method iter(), while ABC Collection checks for iter(), contains() and len().**

### ABC Sequence
* **It's a richer interface than the basic sequence.**
Expand Down Expand Up @@ -2086,7 +2086,7 @@ Memory View

Deque
-----
**List with efficient appends and pops from either side. Pronounced "deck".**
**List with efficient appends and pops from either side.**

```python
from collections import deque
Expand Down Expand Up @@ -2229,7 +2229,7 @@ CRITICAL:my_module:Running out of disk space.
Introspection
-------------
```python
<list> = dir() # List of local names (variables, funcs, classes, modules).
<list> = dir() # Local names of variables, functions, classes and modules.
<dict> = vars() # Dict of local names and their objects. Also locals().
<dict> = globals() # Dict of global names and their objects, e.g. __builtin__.
```
Expand Down
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

<body>
<header>
<aside>December 16, 2024</aside>
<aside>December 18, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>

Expand Down Expand Up @@ -1099,8 +1099,8 @@


<div><h4 id="discrepanciesbetweenglossarydefinitionsandabstractbaseclasses">Discrepancies between glossary definitions and abstract base classes:</h4><ul>
<li><strong>Python's 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>
<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>
<li><strong>Python's glossary defines iterable as any object with special methods iter() and/or getitem() and sequence as any object with getitem() and len(). It doesn't define collection.</strong></li>
<li><strong>Passing ABC Iterable to isinstance() or issubclass() only checks whether object/class has special method iter(), while ABC Collection checks for iter(), contains() and len().</strong></li>
</ul></div>


Expand Down Expand Up @@ -1714,7 +1714,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
&lt;str&gt; = str(&lt;mview&gt;, <span class="hljs-string">'utf-8'</span>) <span class="hljs-comment"># Treats memoryview as a bytes object.</span>
&lt;str&gt; = &lt;mview&gt;.hex() <span class="hljs-comment"># Returns hex pairs. Accepts `sep=&lt;str&gt;`.</span>
</code></pre>
<div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><p><strong>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
<div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><p><strong>List with efficient appends and pops from either side.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque
</code></pre></div>


Expand Down Expand Up @@ -1826,7 +1826,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
</code></pre></div>

<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs">&lt;list&gt; = dir() <span class="hljs-comment"># List of local names (variables, funcs, classes, modules).</span>
<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs">&lt;list&gt; = dir() <span class="hljs-comment"># Local names of variables, functions, classes and modules.</span>
&lt;dict&gt; = vars() <span class="hljs-comment"># Dict of local names and their objects. Also locals().</span>
&lt;dict&gt; = globals() <span class="hljs-comment"># Dict of global names and their objects, e.g. __builtin__.</span>
</code></pre></div>
Expand Down Expand Up @@ -2924,7 +2924,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment


<footer>
<aside>December 16, 2024</aside>
<aside>December 18, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Expand Down

0 comments on commit 1329399

Please sign in to comment.