Skip to content

Commit 41c9e9f

Browse files
committed
Iterable duck types
1 parent 6a22233 commit 41c9e9f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ class MySequence:
12861286
* **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().**
12871287

12881288
### ABC Sequence
1289-
* **It's a richer interface than the basic sequence that also just requires getitem() and len().**
1289+
* **It's a richer interface than the basic sequence that also requires just getitem() and len().**
12901290
* **Extending it generates iter(), contains(), reversed(), index() and count() special methods.**
12911291
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, abc.Sequence)'` would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, array, memoryview and deque, since they are registered as Sequence's virtual subclasses.**
12921292
```python

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@
11131113

11141114

11151115
<div><h3 id="abcsequence">ABC Sequence</h3><ul>
1116-
<li><strong>It's a richer interface than the basic sequence that also just requires getitem() and len().</strong></li>
1116+
<li><strong>It's a richer interface than the basic sequence that also requires just getitem() and len().</strong></li>
11171117
<li><strong>Extending it generates iter(), contains(), reversed(), index() and count() special methods.</strong></li>
11181118
<li><strong>Unlike <code class="python hljs"><span class="hljs-string">'abc.Iterable'</span></code> and <code class="python hljs"><span class="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <code class="python hljs"><span class="hljs-string">'issubclass(MySequence, abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined. It however recognizes list, tuple, range, str, bytes, bytearray, array, memoryview and deque, since they are registered as Sequence's virtual subclasses.</strong></li>
11191119
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> abc

0 commit comments

Comments
 (0)