[Python-Dev] cpython: Issue #16049: add abc.ABC helper class.
Georg Brandl
g.brandl at gmx.net
Sun Dec 16 13:28:24 CET 2012
Am 13.12.2012 18:09, schrieb andrew.svetlov:
> http://hg.python.org/cpython/rev/9347869d1066
> changeset: 80840:9347869d1066
> user: Andrew Svetlov <andrew.svetlov at gmail.com>
> date: Thu Dec 13 19:09:33 2012 +0200
> summary:
> Issue #16049: add abc.ABC helper class.
>
> Patch by Bruno Dupuis.
>
> files:
> Doc/library/abc.rst | 18 ++++++++++++++----
> Lib/abc.py | 6 ++++++
> Lib/test/test_abc.py | 13 +++++++++++++
> Misc/NEWS | 3 +++
> 4 files changed, 36 insertions(+), 4 deletions(-)
>
>
> diff --git a/Doc/library/abc.rst b/Doc/library/abc.rst
> --- a/Doc/library/abc.rst
> +++ b/Doc/library/abc.rst
> @@ -12,9 +12,9 @@
> --------------
>
> This module provides the infrastructure for defining :term:`abstract base
> -classes <abstract base class>` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
> -was added to Python. (See also :pep:`3141` and the :mod:`numbers` module
> -regarding a type hierarchy for numbers based on ABCs.)
> +classes <abstract base class>` (ABCs) in Python, as outlined in :pep:`3119`;
> +see the PEP for why this was added to Python. (See also :pep:`3141` and the
> +:mod:`numbers` module regarding a type hierarchy for numbers based on ABCs.)
>
> The :mod:`collections` module has some concrete classes that derive from
> ABCs; these can, of course, be further derived. In addition the
> @@ -23,7 +23,7 @@
> hashable or a mapping.
>
>
> -This module provides the following class:
> +This module provides the following classes:
>
> .. class:: ABCMeta
>
> @@ -127,6 +127,16 @@
> available as a method of ``Foo``, so it is provided separately.
>
>
> +.. class:: ABC
> +
> + A helper class that has :class:`ABCMeta` as metaclass. :class:`ABC` is the
> + standard class to inherit from in order to create an abstract base class,
> + avoiding sometimes confusing metaclass usage.
> +
> + Note that :class:`ABC` type is still :class:`ABCMeta`, therefore inheriting
> + from :class:`ABC` requires usual precautions regarding metaclasses usage
> + as multiple inheritance may lead to metaclass conflicts.
> +
Needs a versionadded.
Georg
More information about the Python-Dev
mailing list