Skip to content

Commit 6a0c2c7

Browse files
committed
gh-161007: Add a glossary entry for "virtual subclass"
1 parent 4b21d15 commit 6a0c2c7

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

‎Doc/glossary.rst‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ Glossary
2929
Abstract base classes complement :term:`duck-typing` by
3030
providing a way to define interfaces when other techniques like
3131
:func:`hasattr` would be clumsy or subtly wrong (for example with
32-
:ref:`magic methods <special-lookup>`). ABCs introduce virtual
33-
subclasses, which are classes that don't inherit from a class but are
34-
still recognized by :func:`isinstance` and :func:`issubclass`; see the
32+
:ref:`magic methods <special-lookup>`). ABCs introduce
33+
:term:`virtual subclasses <virtual subclass>`, which are classes that
34+
don't inherit from a class but are still recognized by
35+
:func:`isinstance` and :func:`issubclass`; see the
3536
:mod:`abc` module documentation. Python comes with many built-in ABCs for
3637
data structures (in the :mod:`collections.abc` module), numbers (in the
3738
:mod:`numbers` module), streams (in the :mod:`io` module), import finders
@@ -1727,6 +1728,15 @@ Glossary
17271728
A computer defined entirely in software. Python's virtual machine
17281729
executes the :term:`bytecode` emitted by the bytecode compiler.
17291730

1731+
virtual subclass
1732+
A class that :func:`issubclass` and :func:`isinstance` treat as a
1733+
subclass of an :term:`abstract base class` even though it does not
1734+
inherit from it. A class becomes a virtual subclass when it is
1735+
registered with the ABC's :meth:`~abc.ABCMeta.register` method, or when
1736+
the ABC's :meth:`~abc.ABCMeta.__subclasshook__` recognizes it. The ABC
1737+
does not appear in the virtual subclass's :term:`MRO`, and none of the
1738+
ABC's methods are inherited.
1739+
17301740
walrus operator
17311741
A light-hearted way to refer to the :ref:`assignment expression
17321742
<assignment-expressions>` operator ``:=`` because it looks a bit like a

0 commit comments

Comments
 (0)