mirror of https://github.com/python/cpython
Add example for the abc module.
This commit is contained in:
parent
ca904be778
commit
7ec790d1fa
|
@ -815,9 +815,9 @@ collections
|
||||||
|
|
||||||
(Contributed by Raymond Hettinger.)
|
(Contributed by Raymond Hettinger.)
|
||||||
|
|
||||||
* The :class:`collections.deque` grew two new methods :meth:`~collections.deque.count`
|
* The :class:`collections.deque` class grew two new methods
|
||||||
and :meth:`collections.deque.reverse` that make them more substitutable for
|
:meth:`~collections.deque.count` and :meth:`~collections.deque.reverse` that
|
||||||
:class:`list` when needed:
|
make them more substitutable for :class:`list` objects:
|
||||||
|
|
||||||
>>> d = deque('simsalabim')
|
>>> d = deque('simsalabim')
|
||||||
>>> d.count('s')
|
>>> d.count('s')
|
||||||
|
@ -914,9 +914,17 @@ abc
|
||||||
The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
|
The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and
|
||||||
:func:`~abc.abstractstaticmethod`.
|
:func:`~abc.abstractstaticmethod`.
|
||||||
|
|
||||||
These tools make it possible to define an :term:`Abstract Base Class` that
|
These tools make it possible to define an :term:`abstract base class` that
|
||||||
requires a particular :func:`classmethod` or :func:`staticmethod` to be
|
requires a particular :func:`classmethod` or :func:`staticmethod` to be
|
||||||
implemented.
|
implemented::
|
||||||
|
|
||||||
|
class Temperature(metaclass=ABCMeta):
|
||||||
|
@abc.abstractclassmethod
|
||||||
|
def from_farenheit(self, t):
|
||||||
|
...
|
||||||
|
@abc.abstractclassmethod
|
||||||
|
def from_celsium(self, t):
|
||||||
|
...
|
||||||
|
|
||||||
(Patch submitted by Daniel Urban; :issue:`5867`.)
|
(Patch submitted by Daniel Urban; :issue:`5867`.)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue