From 711a407b4d5550e70079f36a4f11dbe866032d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 10 Jan 2021 13:47:09 +0100 Subject: [PATCH] Type --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b6b6ea..e540c19 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ from types import FunctionType, MethodType, LambdaType, GeneratorType ``` ### Abstract Base Classes -**Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not. ABC can also manually decide whether or not a specific class is its virtual subclass, usually based on which methods the class has implemented (Collection, Iterable).** +**Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not. ABC can also manually decide whether or not a specific class is its virtual subclass, usually based on which methods the class has implemented. For instance, Iterable ABC looks for method iter() while Collection ABC looks for methods iter(), contains() and len().** ```python >>> from collections.abc import Sequence, Collection, Iterable diff --git a/index.html b/index.html index 65c5a07..0252554 100644 --- a/index.html +++ b/index.html @@ -415,7 +415,7 @@ to_exclusive = <range>.stop

Some types do not have built-in names, so they must be imported:

from types import FunctionType, MethodType, LambdaType, GeneratorType
 
-

Abstract Base Classes

Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not. ABC can also manually decide whether or not a specific class is its virtual subclass, usually based on which methods the class has implemented (Collection, Iterable).

>>> from collections.abc import Sequence, Collection, Iterable
+

Abstract Base Classes

Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not. ABC can also manually decide whether or not a specific class is its virtual subclass, usually based on which methods the class has implemented. For instance, Iterable ABC looks for method iter() while Collection ABC looks for methods iter(), contains() and len().

>>> from collections.abc import Sequence, Collection, Iterable
 >>> isinstance([1, 2, 3], Iterable)
 True