From babfda1dc9be144daf51affedb520020068838c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sat, 11 Jun 2022 00:22:22 +0200 Subject: [PATCH] Iterable duck types --- README.md | 2 +- index.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8d619a9..6538b50 100644 --- a/README.md +++ b/README.md @@ -1286,7 +1286,7 @@ class MySequence: ### ABC Sequence * **It's a richer interface than the basic sequence.** * **Extending it generates iter(), contains(), reversed(), index() and count().** -* **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.** +* **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 any list, tuple, range, str, bytes, bytearray and memoryview, because they are registered as Sequence's virtual subclasses.** ```python from collections import abc diff --git a/index.html b/index.html index c28a2c3..aa72eaa 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1109,7 +1109,7 @@ Hello World!

ABC Sequence

from collections import abc
 
 class MyAbcSequence(abc.Sequence):
@@ -2901,7 +2901,7 @@ $ pyinstaller script.py --add-data '<path>:.'