structural-typing

collections.abc.Iterable doesn't allows runtime structural checks according to Iterable API

collections.abc.Iterable doesn't allows runtime structural checks according to Iterable API Question: Existing Approaches to Structural Subtyping Abstract classes defined in collections.abc module are slightly more advanced since they implement a custom __subclasshook__() method that allows runtime structural checks without explicit registration: from collections.abc import Iterable class MyIterable: def __iter__(self): return [] assert isinstance(MyIterable(), Iterable) But …

Total answers: 2