collections.abc — Abstract Base Classes for Containers — Python 3.14.7 documentation

docs.python.org

Tin mới

collections — Container datatypes

heapq — Heap queue algorithm

Python Module Index

3.14.7 Documentation

The Python Standard Library

abstract base classes

Added in version 3.3: Formerly, this module was part of the collections module.

Collections Abstract Base Classes¶

Added in version 3.3: Formerly, this module was part of the collections module.

Generic Alias Type

Added in version 3.9: These abstract classes now support []. See Generic Alias Type and PEP 585.

__subclasshook__()

These ABCs override __subclasshook__() to support testing an interface by verifying the required methods are present and have not been set to None. This only works for simple interfaces. More complex interfaces require r

object.__getitem__

Checking isinstance(obj, Iterable) detects classes that are registered as Iterable or that have an __iter__() method, but it does not detect classes that iterate with the __getitem__() method. The only reliable way to de

Annotating callable objects

ABC for classes that provide the __call__() method.

inspect.isawaitable()

In CPython, generator-based coroutines (generators decorated with @types.coroutine) are awaitables, even though they do not have an __await__() method. Using isinstance(gencoro, Awaitable) for them will return False. Use