Mercurial > cpython-lru_cache-weakref
changeset 67666:57bd0d864cb0
Add example for the abc module.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Tue, 18 Jan 2011 00:19:30 +0000 |
| parents | 99eab5edf99d |
| children | f5a3b6397a53 |
| files | Doc/whatsnew/3.2.rst |
| diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Doc/whatsnew/3.2.rst Tue Jan 18 00:02:40 2011 +0000 +++ b/Doc/whatsnew/3.2.rst Tue Jan 18 00:19:30 2011 +0000 @@ -815,9 +815,9 @@ (Contributed by Raymond Hettinger.) -* The :class:`collections.deque` grew two new methods :meth:`~collections.deque.count` - and :meth:`collections.deque.reverse` that make them more substitutable for - :class:`list` when needed: +* The :class:`collections.deque` class grew two new methods + :meth:`~collections.deque.count` and :meth:`~collections.deque.reverse` that + make them more substitutable for :class:`list` objects: >>> d = deque('simsalabim') >>> d.count('s') @@ -914,9 +914,17 @@ The :mod:`abc` module now supports :func:`~abc.abstractclassmethod` and :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 -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`.)
