mirror of
https://github.com/python/cpython.git
synced 2025-07-23 19:25:40 +00:00
Finish the collections ABC table.
Identify which abstract methods need to be defined. Show the inheritance hierarchy. List all of the mixin methods provided automatically.
This commit is contained in:
parent
71909423fd
commit
409fb2c809
1 changed files with 36 additions and 35 deletions
|
@ -30,41 +30,42 @@ ABCs - abstract base classes
|
||||||
|
|
||||||
The collections module offers the following ABCs:
|
The collections module offers the following ABCs:
|
||||||
|
|
||||||
===================================== ================================================================================
|
========================= ==================== ====================== ====================================================
|
||||||
ABC Notes
|
ABC Inherits Abstract Methods Mixin Methods
|
||||||
===================================== ================================================================================
|
========================= ==================== ====================== ====================================================
|
||||||
:class:`collections.Container` Defines ``__contains__()``
|
:class:`Container` ``__contains__``
|
||||||
:class:`collections.Hashable` Defines ``__hash__()``
|
:class:`Hashable` ``__hash__``
|
||||||
:class:`collections.Iterable` Defines ``__iter__()``
|
:class:`Iterable` ``__iter__``
|
||||||
:class:`collections.Iterator` Derived from :class:`Iterable` and in
|
:class:`Iterator` :class:`Iterable` ``__next__`` ``__iter__``
|
||||||
addition defines ``__next__()``
|
:class:`Sized` ``__len__``
|
||||||
:class:`collections.Sized` Defines ``__len__()``
|
|
||||||
:class:`collections.Mapping` Derived from :class:`Container`,
|
:class:`Mapping` :class:`Sized`, ``__getitem__``, ``__contains__``, ``keys``, ``items``, ``values``,
|
||||||
:class:`Iterable`,
|
:class:`Iterable`, ``__len__``. and ``get``, ``__eq__``, and ``__ne__``
|
||||||
and :class:`Sized`, and in addition
|
:class:`Container` ``__iter__``
|
||||||
defines ``__getitem__()``, ``get()``,
|
|
||||||
``__eq__()``, ``__ne__()``,
|
:class:`MutableMapping` :class:`Mapping` ``__getitem__`` Inherited Mapping methods and
|
||||||
``keys()``, ``items()``, and ``values()``
|
``__setitem__``, ``pop``, ``popitem``, ``clear``, ``update``,
|
||||||
:class:`collections.MutableMapping` Derived from :class:`Mapping`
|
``__delitem__``, and ``setdefault``
|
||||||
:class:`collections.Sequence` Derived from :class:`Container`,
|
``__iter__``, and
|
||||||
:class:`Iterable`, and :class:`Sized`,
|
``__len__``
|
||||||
and in addition defines
|
|
||||||
``__getitem__()``
|
:class:`Sequence` :class:`Sized`, ``__getitem__`` ``__contains__``. ``__iter__``, ``__reversed__``.
|
||||||
:class:`collections.MutableSequence` Derived from :class:`Sequence`
|
:class:`Iterable`, and ``__len__`` ``index``, and ``count``
|
||||||
:class:`collections.Set` Derived from :class:`Container`,
|
:class:`Container`
|
||||||
:class:`Iterable`, and :class:`Sized`,
|
|
||||||
add in addition defines
|
:class:`MutableSequnce` :class:`Sequence` ``__getitem__`` Inherited Sequence methods and
|
||||||
``__le__()``, ``__lt__()``,
|
``__delitem__``, ``append``, ``reverse``, ``extend``, ``pop``,
|
||||||
``__eq__()``, ``__and__()``,
|
``insert``, ``remove``, and ``__iadd__``
|
||||||
``__or__()``, ``__sub__()``,
|
and ``__len__``
|
||||||
``__xor__()``, and ``isdisjoint()``,
|
|
||||||
:class:`collections.MutableSet` Derived from :class:`Set` and in
|
:class:`Set` :class:`Sized`, ``__len__``, ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
|
||||||
addition defines ``add()``,
|
:class:`Iterable`, ``__iter__``, and ``__gt__``, ``__ge__``, ``__and__``, ``__or__``
|
||||||
``clear()``, ``discard()``, ``pop()``,
|
:class:`Container` ``__contains__`` ``__sub__``, ``__xor__``, and ``isdisjoint``
|
||||||
``remove()``, ``__ior__()``,
|
|
||||||
``__iand__()``, ``__ixor__()``, and
|
:class:`MutableSet` :class:`Set` ``add`` and Inherited Set methods and
|
||||||
``__isub__()``
|
``discard`` ``clear``, ``pop``, ``remove``, ``__ior__``,
|
||||||
===================================== ================================================================================
|
``__iand__``, ``__ixor__``, and ``__isub__``
|
||||||
|
========================= ==================== ====================== ====================================================
|
||||||
|
|
||||||
These ABCs allow us to ask classes or instances if they provide
|
These ABCs allow us to ask classes or instances if they provide
|
||||||
particular functionality, for example::
|
particular functionality, for example::
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue